diff options
author | Bernd Fix <brf@hoi-polloi.org> | 2022-08-18 14:58:34 +0200 |
---|---|---|
committer | Bernd Fix <brf@hoi-polloi.org> | 2022-08-18 14:58:34 +0200 |
commit | 5b03f7567ad8242cc87924c3920dfc04420365ef (patch) | |
tree | d2e27aca792e1fe8b185e37e571b77c7b7d6a249 /src | |
parent | b62071330cd7e0445e89660d07b7aed098f80285 (diff) | |
download | gnunet-go-5b03f7567ad8242cc87924c3920dfc04420365ef.tar.gz gnunet-go-5b03f7567ad8242cc87924c3920dfc04420365ef.zip |
Prepared for integration test.v0.1.32
Diffstat (limited to 'src')
61 files changed, 2862 insertions, 1829 deletions
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 ( | |||
33 | "gnunet/service" | 33 | "gnunet/service" |
34 | "gnunet/service/dht" | 34 | "gnunet/service/dht" |
35 | "gnunet/service/dht/blocks" | 35 | "gnunet/service/dht/blocks" |
36 | "gnunet/transport" | ||
36 | "gnunet/util" | 37 | "gnunet/util" |
37 | 38 | ||
38 | "github.com/bfix/gospel/logger" | 39 | "github.com/bfix/gospel/logger" |
@@ -44,6 +45,8 @@ func main() { | |||
44 | // flush last messages | 45 | // flush last messages |
45 | logger.Flush() | 46 | logger.Flush() |
46 | }() | 47 | }() |
48 | // intro | ||
49 | logger.SetLogLevel(logger.DBG) | ||
47 | logger.Println(logger.INFO, "[dht] Starting service...") | 50 | logger.Println(logger.INFO, "[dht] Starting service...") |
48 | 51 | ||
49 | var ( | 52 | var ( |
@@ -58,7 +61,7 @@ func main() { | |||
58 | flag.StringVar(&cfgFile, "c", "gnunet-config.json", "GNUnet configuration file") | 61 | flag.StringVar(&cfgFile, "c", "gnunet-config.json", "GNUnet configuration file") |
59 | flag.StringVar(&socket, "s", "", "GNS service socket") | 62 | flag.StringVar(&socket, "s", "", "GNS service socket") |
60 | flag.StringVar(¶m, "p", "", "socket parameters (<key>=<value>,...)") | 63 | flag.StringVar(¶m, "p", "", "socket parameters (<key>=<value>,...)") |
61 | flag.IntVar(&logLevel, "L", logger.DBG, "DHT log level (default: DBG)") | 64 | flag.IntVar(&logLevel, "L", logger.INFO, "DHT log level (default: INFO)") |
62 | flag.StringVar(&rpcEndp, "R", "", "JSON-RPC endpoint (default: none)") | 65 | flag.StringVar(&rpcEndp, "R", "", "JSON-RPC endpoint (default: none)") |
63 | flag.Parse() | 66 | flag.Parse() |
64 | 67 | ||
@@ -69,6 +72,9 @@ func main() { | |||
69 | } | 72 | } |
70 | 73 | ||
71 | // apply configuration | 74 | // apply configuration |
75 | if config.Cfg.Logging.Level > 0 { | ||
76 | logLevel = config.Cfg.Logging.Level | ||
77 | } | ||
72 | logger.SetLogLevel(logLevel) | 78 | logger.SetLogLevel(logLevel) |
73 | if len(socket) == 0 { | 79 | if len(socket) == 0 { |
74 | socket = config.Cfg.DHT.Service.Socket | 80 | socket = config.Cfg.DHT.Service.Socket |
@@ -155,11 +161,12 @@ func main() { | |||
155 | } | 161 | } |
156 | // send HELLO to all bootstrap addresses | 162 | // send HELLO to all bootstrap addresses |
157 | for _, addr := range bsList { | 163 | for _, addr := range bsList { |
158 | if err := dhtSrv.SendHello(ctx, addr); err != nil { | 164 | if err := dhtSrv.SendHello(ctx, addr, "bootstrap"); err != nil { |
159 | logger.Printf(logger.ERROR, "[dht] send HELLO failed: %s", err.Error()) | 165 | if err != transport.ErrEndpMaybeSent { |
166 | logger.Printf(logger.ERROR, "[bootstrap] send HELLO failed: %s", err.Error()) | ||
167 | } | ||
160 | } | 168 | } |
161 | } | 169 | } |
162 | |||
163 | // handle OS signals | 170 | // handle OS signals |
164 | sigCh := make(chan os.Signal, 5) | 171 | sigCh := make(chan os.Signal, 5) |
165 | signal.Notify(sigCh) | 172 | 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 | |||
@@ -134,6 +134,16 @@ type RevocationConfig struct { | |||
134 | } | 134 | } |
135 | 135 | ||
136 | //---------------------------------------------------------------------- | 136 | //---------------------------------------------------------------------- |
137 | // Logging configuration | ||
138 | //---------------------------------------------------------------------- | ||
139 | |||
140 | // LoggingConfig defines the loglevel and logfile location | ||
141 | type LoggingConfig struct { | ||
142 | Level int `json:"level"` | ||
143 | File string `json:"file"` | ||
144 | } | ||
145 | |||
146 | //---------------------------------------------------------------------- | ||
137 | // Combined configuration | 147 | // Combined configuration |
138 | //---------------------------------------------------------------------- | 148 | //---------------------------------------------------------------------- |
139 | 149 | ||
@@ -150,6 +160,7 @@ type Config struct { | |||
150 | GNS *GNSConfig `json:"gns"` | 160 | GNS *GNSConfig `json:"gns"` |
151 | Namecache *NamecacheConfig `json:"namecache"` | 161 | Namecache *NamecacheConfig `json:"namecache"` |
152 | Revocation *RevocationConfig `json:"revocation"` | 162 | Revocation *RevocationConfig `json:"revocation"` |
163 | Logging *LoggingConfig `json:"logging"` | ||
153 | } | 164 | } |
154 | 165 | ||
155 | var ( | 166 | 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 @@ | |||
83 | }, | 83 | }, |
84 | "rpc": { | 84 | "rpc": { |
85 | "endpoint": "tcp:127.0.0.1:80" | 85 | "endpoint": "tcp:127.0.0.1:80" |
86 | }, | ||
87 | "logging": { | ||
88 | "level": 4, | ||
89 | "file": "/tmp/gnunet-go/run.log" | ||
86 | } | 90 | } |
87 | } \ No newline at end of file | 91 | } \ 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 | |||
20 | 20 | ||
21 | import ( | 21 | import ( |
22 | "context" | 22 | "context" |
23 | "encoding/hex" | ||
24 | "errors" | 23 | "errors" |
25 | "gnunet/config" | 24 | "gnunet/config" |
26 | "gnunet/crypto" | 25 | "gnunet/crypto" |
@@ -42,6 +41,9 @@ var ( | |||
42 | ErrCoreNotSent = errors.New("message not sent") | 41 | ErrCoreNotSent = errors.New("message not sent") |
43 | ) | 42 | ) |
44 | 43 | ||
44 | // CtxKey is a value-context key | ||
45 | type CtxKey string | ||
46 | |||
45 | //---------------------------------------------------------------------- | 47 | //---------------------------------------------------------------------- |
46 | // EndpointRef is a reference to an endpoint instance managed by core. | 48 | // EndpointRef is a reference to an endpoint instance managed by core. |
47 | type EndpointRef struct { | 49 | type EndpointRef struct { |
@@ -85,7 +87,7 @@ func NewCore(ctx context.Context, node *config.NodeConfig) (c *Core, err error) | |||
85 | if peer, err = NewLocalPeer(node); err != nil { | 87 | if peer, err = NewLocalPeer(node); err != nil { |
86 | return | 88 | return |
87 | } | 89 | } |
88 | logger.Printf(logger.DBG, "[core] Local node is %s", peer.GetID().String()) | 90 | logger.Printf(logger.INFO, "[core] Local node is %s", peer.GetID().Short()) |
89 | 91 | ||
90 | // create new core instance | 92 | // create new core instance |
91 | incoming := make(chan *transport.Message) | 93 | incoming := make(chan *transport.Message) |
@@ -166,7 +168,7 @@ func (c *Core) pump(ctx context.Context) { | |||
166 | select { | 168 | select { |
167 | // get (next) message from transport | 169 | // get (next) message from transport |
168 | case tm := <-c.incoming: | 170 | case tm := <-c.incoming: |
169 | logger.Printf(logger.DBG, "[core] Message received from %s: %s", tm.Peer, util.Dump(tm.Msg, "json")) | 171 | logger.Printf(logger.DBG, "[core] Message received from %s: %s", tm.Peer.Short(), tm.Msg) |
170 | 172 | ||
171 | // check if peer is already connected (has an entry in PeerAddrist) | 173 | // check if peer is already connected (has an entry in PeerAddrist) |
172 | _, connected := c.connected.Get(tm.Peer.String(), 0) | 174 | _, connected := c.connected.Get(tm.Peer.String(), 0) |
@@ -217,6 +219,14 @@ func (c *Core) Shutdown() { | |||
217 | // Send is a function that allows the local peer to send a protocol | 219 | // Send is a function that allows the local peer to send a protocol |
218 | // message to a remote peer. | 220 | // message to a remote peer. |
219 | func (c *Core) Send(ctx context.Context, peer *util.PeerID, msg message.Message) (err error) { | 221 | func (c *Core) Send(ctx context.Context, peer *util.PeerID, msg message.Message) (err error) { |
222 | // assemble log label | ||
223 | label := "core" | ||
224 | if v := ctx.Value(CtxKey("label")); v != nil { | ||
225 | if s, ok := v.(string); ok && len(s) > 0 { | ||
226 | label = s | ||
227 | } | ||
228 | } | ||
229 | |||
220 | // TODO: select best endpoint protocol for transport; now fixed to IP+UDP | 230 | // TODO: select best endpoint protocol for transport; now fixed to IP+UDP |
221 | netw := "ip+udp" | 231 | netw := "ip+udp" |
222 | 232 | ||
@@ -224,12 +234,12 @@ func (c *Core) Send(ctx context.Context, peer *util.PeerID, msg message.Message) | |||
224 | aList := c.peers.Get(peer, netw) | 234 | aList := c.peers.Get(peer, netw) |
225 | maybe := false // message may be sent... | 235 | maybe := false // message may be sent... |
226 | for _, addr := range aList { | 236 | for _, addr := range aList { |
227 | logger.Printf(logger.INFO, "[core] Trying to send to %s", addr.URI()) | 237 | logger.Printf(logger.INFO, "[%s] Trying to send to %s", label, addr.URI()) |
228 | // send message to address | 238 | // send message to address |
229 | if err = c.SendToAddr(ctx, addr, msg); err != nil { | 239 | if err = c.SendToAddr(ctx, addr, msg); err != nil { |
230 | // if it is possible that the message was not sent, try next address | 240 | // if it is possible that the message was not sent, try next address |
231 | if err != transport.ErrEndpMaybeSent { | 241 | if err != transport.ErrEndpMaybeSent { |
232 | logger.Printf(logger.WARN, "[core] Failed to send to %s: %s", addr.URI(), err.Error()) | 242 | logger.Printf(logger.WARN, "[%s] Failed to send to %s: %s", label, addr.URI(), err.Error()) |
233 | } else { | 243 | } else { |
234 | maybe = true | 244 | maybe = true |
235 | } | 245 | } |
@@ -239,7 +249,6 @@ func (c *Core) Send(ctx context.Context, peer *util.PeerID, msg message.Message) | |||
239 | return | 249 | return |
240 | } | 250 | } |
241 | if maybe { | 251 | if maybe { |
242 | logger.Printf(logger.WARN, "[core] %s", transport.ErrEndpMaybeSent.Error()) | ||
243 | err = nil | 252 | err = nil |
244 | } else { | 253 | } else { |
245 | err = ErrCoreNotSent | 254 | err = ErrCoreNotSent |
@@ -256,7 +265,9 @@ func (c *Core) SendToAddr(ctx context.Context, addr *util.Address, msg message.M | |||
256 | } | 265 | } |
257 | 266 | ||
258 | // Learn (new) addresses for peer | 267 | // Learn (new) addresses for peer |
259 | func (c *Core) Learn(ctx context.Context, peer *util.PeerID, addrs []*util.Address) (newPeer bool) { | 268 | func (c *Core) Learn(ctx context.Context, peer *util.PeerID, addrs []*util.Address, label string) (newPeer bool) { |
269 | logger.Printf(logger.DBG, "[%s] Learning %v for %s", label, addrs, peer.Short()) | ||
270 | |||
260 | // learn all addresses for peer | 271 | // learn all addresses for peer |
261 | newPeer = false | 272 | newPeer = false |
262 | for _, addr := range addrs { | 273 | for _, addr := range addrs { |
@@ -265,7 +276,8 @@ func (c *Core) Learn(ctx context.Context, peer *util.PeerID, addrs []*util.Addre | |||
265 | continue | 276 | continue |
266 | } | 277 | } |
267 | // learn address | 278 | // learn address |
268 | logger.Printf(logger.INFO, "[core] Learning %s for %s (expires %s)", addr.URI(), peer, addr.Expires) | 279 | logger.Printf(logger.INFO, "[%s] Learning %s for %s (expires %s)", |
280 | label, addr.URI(), peer.Short(), addr.Expire) | ||
269 | newPeer = (c.peers.Add(peer, addr) == 1) || newPeer | 281 | newPeer = (c.peers.Add(peer, addr) == 1) || newPeer |
270 | } | 282 | } |
271 | return | 283 | return |
@@ -296,12 +308,10 @@ func (c *Core) PeerID() *util.PeerID { | |||
296 | // Sign a signable onject with private peer key | 308 | // Sign a signable onject with private peer key |
297 | func (c *Core) Sign(obj crypto.Signable) error { | 309 | func (c *Core) Sign(obj crypto.Signable) error { |
298 | sd := obj.SignedData() | 310 | sd := obj.SignedData() |
299 | logger.Printf(logger.DBG, "[core] Signing data '%s'", hex.EncodeToString(sd)) | ||
300 | sig, err := c.local.prv.EdSign(sd) | 311 | sig, err := c.local.prv.EdSign(sd) |
301 | if err != nil { | 312 | if err != nil { |
302 | return err | 313 | return err |
303 | } | 314 | } |
304 | logger.Printf(logger.DBG, "[core] --> signature '%s'", hex.EncodeToString(sig.Bytes())) | ||
305 | return obj.SetSignature(util.NewPeerSignature(sig.Bytes())) | 315 | return obj.SetSignature(util.NewPeerSignature(sig.Bytes())) |
306 | } | 316 | } |
307 | 317 | ||
@@ -357,12 +367,11 @@ func (c *Core) Unregister(name string) *Listener { | |||
357 | 367 | ||
358 | // internal: dispatch event to listeners | 368 | // internal: dispatch event to listeners |
359 | func (c *Core) dispatch(ev *Event) { | 369 | func (c *Core) dispatch(ev *Event) { |
360 | logger.Printf(logger.DBG, "[core] Dispatching %v...", ev) | ||
361 | // dispatch event to listeners | 370 | // dispatch event to listeners |
362 | for _, l := range c.listeners { | 371 | for _, l := range c.listeners { |
363 | if l.filter.CheckEvent(ev.ID) { | 372 | if l.filter.CheckEvent(ev.ID) { |
364 | if ev.ID == EV_MESSAGE { | 373 | if ev.ID == EV_MESSAGE { |
365 | mt := ev.Msg.Header().MsgType | 374 | mt := ev.Msg.Type() |
366 | if mt != 0 && !l.filter.CheckMsgType(mt) { | 375 | if mt != 0 && !l.filter.CheckMsgType(mt) { |
367 | // skip event | 376 | // skip event |
368 | return | 377 | 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 | |||
249 | label = peer.String() | 249 | label = peer.String() |
250 | } | 250 | } |
251 | n.t.Logf("[%d] Learning %s for %s", n.id, addr.URI(), label) | 251 | n.t.Logf("[%d] Learning %s for %s", n.id, addr.URI(), label) |
252 | n.core.Learn(ctx, peer, []*util.Address{addr}) | 252 | n.core.Learn(ctx, peer, []*util.Address{addr}, label) |
253 | } | 253 | } |
254 | 254 | ||
255 | func NewTestNode(ctx context.Context, t *testing.T, cfg *config.NodeConfig) (node *TestNode, err error) { | 255 | 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 | |||
298 | case EV_DISCONNECT: | 298 | case EV_DISCONNECT: |
299 | t.Logf("[%d] <<< Peer %s diconnected", node.id, ev.Peer) | 299 | t.Logf("[%d] <<< Peer %s diconnected", node.id, ev.Peer) |
300 | case EV_MESSAGE: | 300 | case EV_MESSAGE: |
301 | t.Logf("[%d] <<< Msg from %s of type %d", node.id, ev.Peer, ev.Msg.Header().MsgType) | 301 | t.Logf("[%d] <<< Msg from %s of type %s", node.id, ev.Peer, ev.Msg.Type()) |
302 | t.Logf("[%d] <<< --> %s", node.id, ev.Msg.String()) | 302 | t.Logf("[%d] <<< --> %s", node.id, ev.Msg.String()) |
303 | wrt := new(bytes.Buffer) | 303 | wrt := new(bytes.Buffer) |
304 | if err := transport.WriteMessageDirect(wrt, ev.Msg); err == nil { | 304 | 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 | |||
20 | 20 | ||
21 | import ( | 21 | import ( |
22 | "fmt" | 22 | "fmt" |
23 | "gnunet/enums" | ||
23 | "gnunet/message" | 24 | "gnunet/message" |
24 | "gnunet/transport" | 25 | "gnunet/transport" |
25 | "gnunet/util" | 26 | "gnunet/util" |
@@ -42,14 +43,14 @@ const ( | |||
42 | // can be filtered by message type also. | 43 | // can be filtered by message type also. |
43 | type EventFilter struct { | 44 | type EventFilter struct { |
44 | evTypes map[int]bool | 45 | evTypes map[int]bool |
45 | msgTypes map[uint16]bool | 46 | msgTypes map[enums.MsgType]bool |
46 | } | 47 | } |
47 | 48 | ||
48 | // NewEventFilter creates a new empty filter instance. | 49 | // NewEventFilter creates a new empty filter instance. |
49 | func NewEventFilter() *EventFilter { | 50 | func NewEventFilter() *EventFilter { |
50 | return &EventFilter{ | 51 | return &EventFilter{ |
51 | evTypes: make(map[int]bool), | 52 | evTypes: make(map[int]bool), |
52 | msgTypes: make(map[uint16]bool), | 53 | msgTypes: make(map[enums.MsgType]bool), |
53 | } | 54 | } |
54 | } | 55 | } |
55 | 56 | ||
@@ -59,7 +60,7 @@ func (f *EventFilter) AddEvent(ev int) { | |||
59 | } | 60 | } |
60 | 61 | ||
61 | // AddMsgType adds a message type to filter | 62 | // AddMsgType adds a message type to filter |
62 | func (f *EventFilter) AddMsgType(mt uint16) { | 63 | func (f *EventFilter) AddMsgType(mt enums.MsgType) { |
63 | f.evTypes[EV_MESSAGE] = true | 64 | f.evTypes[EV_MESSAGE] = true |
64 | f.msgTypes[mt] = true | 65 | f.msgTypes[mt] = true |
65 | } | 66 | } |
@@ -76,7 +77,7 @@ func (f *EventFilter) CheckEvent(ev int) bool { | |||
76 | 77 | ||
77 | // CheckMsgType returns true if a message type is matched | 78 | // CheckMsgType returns true if a message type is matched |
78 | // by the filter or the filter is empty. | 79 | // by the filter or the filter is empty. |
79 | func (f *EventFilter) CheckMsgType(mt uint16) bool { | 80 | func (f *EventFilter) CheckMsgType(mt enums.MsgType) bool { |
80 | if len(f.msgTypes) == 0 { | 81 | if len(f.msgTypes) == 0 { |
81 | return true | 82 | return true |
82 | } | 83 | } |
@@ -103,7 +104,7 @@ func (e *Event) String() string { | |||
103 | } | 104 | } |
104 | s += fmt.Sprintf("id=%d,peer=%s", e.ID, e.Peer) | 105 | s += fmt.Sprintf("id=%d,peer=%s", e.ID, e.Peer) |
105 | if e.Msg != nil { | 106 | if e.Msg != nil { |
106 | s += fmt.Sprintf(",msg=%d", e.Msg.Header().MsgType) | 107 | s += fmt.Sprintf(",msg=%s", e.Msg.Type()) |
107 | } | 108 | } |
108 | return s + "}" | 109 | return s + "}" |
109 | } | 110 | } |
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 | |||
103 | // assemble HELLO data | 103 | // assemble HELLO data |
104 | h = new(blocks.HelloBlock) | 104 | h = new(blocks.HelloBlock) |
105 | h.PeerID = p.GetID() | 105 | h.PeerID = p.GetID() |
106 | h.Expires = util.NewAbsoluteTime(time.Now().Add(ttl)) | 106 | h.Expire_ = util.NewAbsoluteTime(time.Now().Add(ttl)) |
107 | h.SetAddresses(a) | 107 | h.SetAddresses(a) |
108 | 108 | ||
109 | // sign data | 109 | // 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) { | |||
75 | t.Log(u2) | 75 | t.Log(u2) |
76 | 76 | ||
77 | // check if HELLO data is the same | 77 | // check if HELLO data is the same |
78 | if !h.Equals(h2) { | 78 | if !h.Equal(h2) { |
79 | t.Fatal("HELLO data mismatch") | 79 | t.Fatal("HELLO data mismatch") |
80 | } | 80 | } |
81 | // verify signature | 81 | // 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 | |||
132 | 132 | ||
133 | // BlockKey return the symmetric key (and initialization vector) based on | 133 | // BlockKey return the symmetric key (and initialization vector) based on |
134 | // label and expiration time. | 134 | // label and expiration time. |
135 | func (pk *EDKEYPublicImpl) BlockKey(label string, expires util.AbsoluteTime) (skey []byte) { | 135 | func (pk *EDKEYPublicImpl) BlockKey(label string, expire util.AbsoluteTime) (skey []byte) { |
136 | // generate symmetric key | 136 | // generate symmetric key |
137 | skey = make([]byte, 56) | 137 | skey = make([]byte, 56) |
138 | kd := pk.Bytes() | 138 | kd := pk.Bytes() |
@@ -143,11 +143,11 @@ func (pk *EDKEYPublicImpl) BlockKey(label string, expires util.AbsoluteTime) (sk | |||
143 | } | 143 | } |
144 | // assemble initialization vector | 144 | // assemble initialization vector |
145 | iv := &struct { | 145 | iv := &struct { |
146 | Nonce []byte `size:"16"` // Nonce | 146 | Nonce []byte `size:"16"` // Nonce |
147 | Expiration util.AbsoluteTime `` // Expiration time of block | 147 | Expire util.AbsoluteTime `` // Expiration time of block |
148 | }{ | 148 | }{ |
149 | Nonce: make([]byte, 16), | 149 | Nonce: make([]byte, 16), |
150 | Expiration: expires, | 150 | Expire: expire, |
151 | } | 151 | } |
152 | prk = hkdf.Extract(sha512.New, kd, []byte("gns-xsalsa-ctx-iv")) | 152 | prk = hkdf.Extract(sha512.New, kd, []byte("gns-xsalsa-ctx-iv")) |
153 | rdr = hkdf.Expand(sha256.New, prk, []byte(label)) | 153 | 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 | |||
121 | 121 | ||
122 | // assemble initialization vector | 122 | // assemble initialization vector |
123 | iv := &struct { | 123 | iv := &struct { |
124 | Nonce []byte `size:"4"` // 32 bit Nonce | 124 | Nonce []byte `size:"4"` // 32 bit Nonce |
125 | Expiration util.AbsoluteTime `` // Expiration time of block | 125 | Expire util.AbsoluteTime `` // Expiration time of block |
126 | Counter uint32 `order:"big"` // Block counter | 126 | Counter uint32 `order:"big"` // Block counter |
127 | }{ | 127 | }{ |
128 | Nonce: make([]byte, 4), | 128 | Nonce: make([]byte, 4), |
129 | Expiration: expires, | 129 | Expire: expires, |
130 | Counter: 1, | 130 | Counter: 1, |
131 | } | 131 | } |
132 | prk = hkdf.Extract(sha512.New, kd, []byte("gns-aes-ctx-iv")) | 132 | prk = hkdf.Extract(sha512.New, kd, []byte("gns-aes-ctx-iv")) |
133 | rdr = hkdf.Expand(sha256.New, prk, []byte(label)) | 133 | 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 ( | |||
28 | 28 | ||
29 | // HashCode is the result of a 512-bit hash function (SHA-512) | 29 | // HashCode is the result of a 512-bit hash function (SHA-512) |
30 | type HashCode struct { | 30 | type HashCode struct { |
31 | Bits []byte `size:"(Size))"` | 31 | Data []byte `size:"(Size)"` |
32 | } | 32 | } |
33 | 33 | ||
34 | // Equals tests if two hash results are equal. | 34 | // Equal tests if two hash results are equal. |
35 | func (hc *HashCode) Equals(n *HashCode) bool { | 35 | func (hc *HashCode) Equal(n *HashCode) bool { |
36 | return bytes.Equal(hc.Bits, n.Bits) | 36 | return bytes.Equal(hc.Data, n.Data) |
37 | } | 37 | } |
38 | 38 | ||
39 | // Size of binary data | 39 | // Size of binary data |
@@ -44,13 +44,18 @@ func (hc *HashCode) Size() uint { | |||
44 | // Clone the hash code | 44 | // Clone the hash code |
45 | func (hc *HashCode) Clone() *HashCode { | 45 | func (hc *HashCode) Clone() *HashCode { |
46 | return &HashCode{ | 46 | return &HashCode{ |
47 | Bits: util.Clone(hc.Bits), | 47 | Data: util.Clone(hc.Data), |
48 | } | 48 | } |
49 | } | 49 | } |
50 | 50 | ||
51 | // String returns a hex-representation of the hash code | 51 | // String returns a hex-representation of the hash code |
52 | func (hc *HashCode) String() string { | 52 | func (hc *HashCode) String() string { |
53 | return hex.EncodeToString(hc.Bits) | 53 | return hex.EncodeToString(hc.Data) |
54 | } | ||
55 | |||
56 | // Short returns a short key representation | ||
57 | func (hc *HashCode) Short() string { | ||
58 | return util.Shorten(hc.String(), 20) | ||
54 | } | 59 | } |
55 | 60 | ||
56 | // NewHashCode creates a new (initialized) hash value | 61 | // NewHashCode creates a new (initialized) hash value |
@@ -65,7 +70,7 @@ func NewHashCode(data []byte) *HashCode { | |||
65 | copy(v, data[:size]) | 70 | copy(v, data[:size]) |
66 | } | 71 | } |
67 | } | 72 | } |
68 | hc.Bits = v | 73 | hc.Data = v |
69 | return hc | 74 | return hc |
70 | } | 75 | } |
71 | 76 | ||
@@ -73,6 +78,6 @@ func NewHashCode(data []byte) *HashCode { | |||
73 | func Hash(data []byte) *HashCode { | 78 | func Hash(data []byte) *HashCode { |
74 | val := sha512.Sum512(data) | 79 | val := sha512.Sum512(data) |
75 | return &HashCode{ | 80 | return &HashCode{ |
76 | Bits: util.Clone(val[:]), | 81 | Data: util.Clone(val[:]), |
77 | } | 82 | } |
78 | } | 83 | } |
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 ( | |||
26 | DHT_RO_RECORD_ROUTE = 2 // keep track of the route that the message took in the P2P network. | 26 | DHT_RO_RECORD_ROUTE = 2 // keep track of the route that the message took in the P2P network. |
27 | DHT_RO_FIND_APPROXIMATE = 4 // Approximate results are fine. | 27 | DHT_RO_FIND_APPROXIMATE = 4 // Approximate results are fine. |
28 | DHT_RO_TRUNCATED = 8 // Flag if path is truncated | 28 | DHT_RO_TRUNCATED = 8 // Flag if path is truncated |
29 | |||
30 | DHT_RO_DISCOVERY = 32768 // Peer discovery | ||
29 | ) | 31 | ) |
30 | 32 | ||
31 | //go:generate go run generate.go gnunet-dht.rec gnunet-dht.tpl dht_block_type.go | 33 | //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 @@ | |||
3 | //nolint:stylecheck // allow non-camel-case for constants | 3 | //nolint:stylecheck // allow non-camel-case for constants |
4 | package enums | 4 | package enums |
5 | 5 | ||
6 | type BlockType uint16 | 6 | type BlockType uint32 |
7 | 7 | ||
8 | // DHT block types | 8 | // DHT block types |
9 | const ( | 9 | 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 @@ | |||
3 | //nolint:stylecheck // allow non-camel-case for constants | 3 | //nolint:stylecheck // allow non-camel-case for constants |
4 | package enums | 4 | package enums |
5 | 5 | ||
6 | type BlockType uint16 | 6 | type BlockType uint32 |
7 | 7 | ||
8 | // DHT block types | 8 | // DHT block types |
9 | const ( | 9 | 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 @@ | |||
1 | // This file is part of gnunet-go, a GNUnet-implementation in Golang. | ||
2 | // Copyright (C) 2019-2022 Bernd Fix >Y< | ||
3 | // | ||
4 | // gnunet-go is free software: you can redistribute it and/or modify it | ||
5 | // under the terms of the GNU Affero General Public License as published | ||
6 | // by the Free Software Foundation, either version 3 of the License, | ||
7 | // or (at your option) any later version. | ||
8 | // | ||
9 | // gnunet-go is distributed in the hope that it will be useful, but | ||
10 | // WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | // Affero General Public License for more details. | ||
13 | // | ||
14 | // You should have received a copy of the GNU Affero General Public License | ||
15 | // along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | // | ||
17 | // SPDX-License-Identifier: AGPL3.0-or-later | ||
18 | |||
19 | //nolint:stylecheck // allow non-camel-case in constants | ||
20 | package enums | ||
21 | |||
22 | // MsgType for GNUnet message type identifiers | ||
23 | //go:generate stringer -type=MsgType | ||
24 | type MsgType uint16 | ||
25 | |||
26 | // GNUnet message types | ||
27 | const ( | ||
28 | MSG_TEST MsgType = 1 // Test if service is online (deprecated) | ||
29 | MSG_DUMMY MsgType = 2 // Dummy messages for testing / benchmarking | ||
30 | MSG_DUMMY2 MsgType = 3 // Another dummy messages for testing / benchmarking | ||
31 | |||
32 | //------------------------------------------------------------------ | ||
33 | // RESOLVER message types | ||
34 | //------------------------------------------------------------------ | ||
35 | |||
36 | MSG_RESOLVER_REQUEST MsgType = 4 // Request DNS resolution | ||
37 | MSG_RESOLVER_RESPONSE MsgType = 5 // Response to a DNS resolution request | ||
38 | |||
39 | //------------------------------------------------------------------ | ||
40 | // AGPL source code download | ||
41 | //------------------------------------------------------------------ | ||
42 | |||
43 | MSG_REQUEST_AGPL MsgType = 6 // Message to request source code link | ||
44 | MSG_RESPONSE_AGPL MsgType = 7 // Source code link | ||
45 | |||
46 | //------------------------------------------------------------------ | ||
47 | // ARM message types | ||
48 | //------------------------------------------------------------------ | ||
49 | |||
50 | MSG_ARM_START MsgType = 8 // Request to ARM to start a service | ||
51 | MSG_ARM_STOP MsgType = 9 // Request to ARM to stop a service | ||
52 | MSG_ARM_RESULT MsgType = 10 // Response from ARM | ||
53 | MSG_ARM_STATUS MsgType = 11 // Status update from ARM | ||
54 | MSG_ARM_LIST MsgType = 12 // Request to ARM to list all currently running services | ||
55 | MSG_ARM_LIST_RESULT MsgType = 13 // Response from ARM for listing currently running services | ||
56 | MSG_ARM_MONITOR MsgType = 14 // Request to ARM to notify client of service status changes | ||
57 | MSG_ARM_TEST MsgType = 15 // Test if ARM service is online | ||
58 | |||
59 | //------------------------------------------------------------------ | ||
60 | // HELLO message types | ||
61 | //------------------------------------------------------------------ | ||
62 | |||
63 | MSG_HELLO_LEGACY MsgType = 16 // Deprecated HELLO message | ||
64 | MSG_HELLO MsgType = 17 // HELLO message with friend_only flag | ||
65 | |||
66 | //------------------------------------------------------------------ | ||
67 | // FRAGMENTATION message types | ||
68 | //------------------------------------------------------------------ | ||
69 | |||
70 | MSG_FRAGMENT MsgType = 18 // FRAGMENT of a larger message | ||
71 | MSG_FRAGMENT_ACK MsgType = 19 // Acknowledgement of a FRAGMENT of a larger message | ||
72 | |||
73 | //------------------------------------------------------------------ | ||
74 | // Transport-WLAN message types | ||
75 | //------------------------------------------------------------------ | ||
76 | |||
77 | MSG_WLAN_DATA_TO_HELPER MsgType = 39 // Type of data messages from the plugin to the gnunet-wlan-helper | ||
78 | MSG_WLAN_DATA_FROM_HELPER MsgType = 40 // Type of data messages from the gnunet-wlan-helper to the plugin | ||
79 | MSG_WLAN_HELPER_CONTROL MsgType = 41 // Control message between the gnunet-wlan-helper and the daemon (with the MAC) | ||
80 | MSG_WLAN_ADVERTISEMENT MsgType = 42 // Type of messages for advertisement over wlan | ||
81 | MSG_WLAN_DATA MsgType = 43 // Type of messages for data over the wlan | ||
82 | |||
83 | //------------------------------------------------------------------ | ||
84 | // Transport-DV message types | ||
85 | //------------------------------------------------------------------ | ||
86 | |||
87 | MSG_DV_RECV MsgType = 44 // DV service to DV Plugin message | ||
88 | MSG_DV_SEND MsgType = 45 // DV Plugin to DV service message | ||
89 | MSG_DV_SEND_ACK MsgType = 46 // Confirmation or failure of a DV_SEND message | ||
90 | MSG_DV_ROUTE MsgType = 47 // P2P DV message encapsulating some real message | ||
91 | MSG_DV_START MsgType = 48 // DV Plugin to DV service message, indicating startup. | ||
92 | MSG_DV_CONNECT MsgType = 49 // P2P DV message telling plugin that a peer connected | ||
93 | MSG_DV_DISCONNECT MsgType = 50 // P2P DV message telling plugin that a peer disconnected | ||
94 | MSG_DV_SEND_NACK MsgType = 51 // P2P DV message telling plugin that a message transmission failed (negative ACK) | ||
95 | MSG_DV_DISTANCE_CHANGED MsgType = 52 // P2P DV message telling plugin that our distance to a peer changed | ||
96 | MSG_DV_BOX MsgType = 53 // DV message box for boxing multiple messages. | ||
97 | MSG_TRANSPORT_XU_MESSAGE MsgType = 55 // Experimental message type. | ||
98 | |||
99 | //------------------------------------------------------------------ | ||
100 | // Transport-UDP message types | ||
101 | //------------------------------------------------------------------ | ||
102 | |||
103 | MSG_TRANSPORT_UDP_MESSAGE MsgType = 56 // Normal UDP message type. | ||
104 | MSG_TRANSPORT_UDP_ACK MsgType = 57 // UDP ACK. | ||
105 | |||
106 | //------------------------------------------------------------------ | ||
107 | // Transport-TCP message types | ||
108 | //------------------------------------------------------------------ | ||
109 | |||
110 | MSG_TRANSPORT_TCP_NAT_PROBE MsgType = 60 // TCP NAT probe message | ||
111 | MSG_TRANSPORT_TCP_WELCOME MsgType = 61 // Welcome message between TCP transports. | ||
112 | MSG_TRANSPORT_ATS MsgType = 62 // Message to force transport to update bandwidth assignment (LEGACY) | ||
113 | |||
114 | //------------------------------------------------------------------ | ||
115 | // NAT message types | ||
116 | //------------------------------------------------------------------ | ||
117 | |||
118 | MSG_NAT_TEST MsgType = 63 // Message to ask NAT server to perform traversal test | ||
119 | |||
120 | //------------------------------------------------------------------ | ||
121 | // CORE message types | ||
122 | //------------------------------------------------------------------ | ||
123 | |||
124 | MSG_CORE_INIT MsgType = 64 // Initial setup message from core client to core. | ||
125 | MSG_CORE_INIT_REPLY MsgType = 65 // Response from core to core client to INIT message. | ||
126 | MSG_CORE_NOTIFY_CONNECT MsgType = 67 // Notify clients about new peer-to-peer connections (triggered after key exchange). | ||
127 | MSG_CORE_NOTIFY_DISCONNECT MsgType = 68 // Notify clients about peer disconnecting. | ||
128 | MSG_CORE_NOTIFY_STATUS_CHANGE MsgType = 69 // Notify clients about peer status change. | ||
129 | MSG_CORE_NOTIFY_INBOUND MsgType = 70 // Notify clients about incoming P2P messages. | ||
130 | MSG_CORE_NOTIFY_OUTBOUND MsgType = 71 // Notify clients about outgoing P2P transmissions. | ||
131 | MSG_CORE_SEND_REQUEST MsgType = 74 // Request from client to transmit message. | ||
132 | MSG_CORE_SEND_READY MsgType = 75 // Confirmation from core that message can now be sent | ||
133 | MSG_CORE_SEND MsgType = 76 // Client with message to transmit (after SEND_READY confirmation was received). | ||
134 | MSG_CORE_MONITOR_PEERS MsgType = 78 // Request for connection monitoring from CORE service. | ||
135 | MSG_CORE_MONITOR_NOTIFY MsgType = 79 // Reply for monitor by CORE service. | ||
136 | MSG_CORE_ENCRYPTED_MESSAGE MsgType = 82 // Encapsulation for an encrypted message between peers. | ||
137 | MSG_CORE_PING MsgType = 83 // Check that other peer is alive (challenge). | ||
138 | MSG_CORE_PONG MsgType = 84 // Confirmation that other peer is alive. | ||
139 | MSG_CORE_HANGUP MsgType = 85 // Request by the other peer to terminate the connection. | ||
140 | MSG_CORE_COMPRESSED_TYPE_MAP MsgType = 86 // gzip-compressed type map of the sender | ||
141 | MSG_CORE_BINARY_TYPE_MAP MsgType = 87 // uncompressed type map of the sender | ||
142 | MSG_CORE_EPHEMERAL_KEY MsgType = 88 // Session key exchange between peers. | ||
143 | MSG_CORE_CONFIRM_TYPE_MAP MsgType = 89 // Other peer confirms having received the type map | ||
144 | |||
145 | //------------------------------------------------------------------ | ||
146 | // DATASTORE message types | ||
147 | //------------------------------------------------------------------ | ||
148 | |||
149 | MSG_DATASTORE_RESERVE MsgType = 92 // Message sent by datastore client on join. | ||
150 | MSG_DATASTORE_RELEASE_RESERVE MsgType = 93 // Message sent by datastore client on join. | ||
151 | 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). | ||
152 | MSG_DATASTORE_PUT MsgType = 95 // Message sent by datastore client to store data. | ||
153 | MSG_DATASTORE_GET MsgType = 97 // Message sent by datastore client to get data. | ||
154 | MSG_DATASTORE_GET_REPLICATION MsgType = 98 // Message sent by datastore client to get random data. | ||
155 | MSG_DATASTORE_GET_ZERO_ANONYMITY MsgType = 99 // Message sent by datastore client to get random data. | ||
156 | MSG_DATASTORE_DATA MsgType = 100 // Message sent by datastore to client providing requested data (in response to GET or GET_RANDOM request). | ||
157 | 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. | ||
158 | MSG_DATASTORE_REMOVE MsgType = 102 // Message sent by datastore client to remove data. | ||
159 | MSG_DATASTORE_DROP MsgType = 103 // Message sent by datastore client to drop the database. | ||
160 | MSG_DATASTORE_GET_KEY MsgType = 104 // Message sent by datastore client to get data by key. | ||
161 | |||
162 | //------------------------------------------------------------------ | ||
163 | // FS message types | ||
164 | //------------------------------------------------------------------ | ||
165 | |||
166 | MSG_FS_REQUEST_LOC_SIGN MsgType = 126 // Message sent by fs client to request LOC signature. | ||
167 | MSG_FS_REQUEST_LOC_SIGNATURE MsgType = 127 // Reply sent by fs service with LOC signature. | ||
168 | MSG_FS_INDEX_START MsgType = 128 // Message sent by fs client to start indexing. | ||
169 | MSG_FS_INDEX_START_OK MsgType = 129 // Affirmative response to a request for start indexing. | ||
170 | MSG_FS_INDEX_START_FAILED MsgType = 130 // Response to a request for start indexing that refuses. | ||
171 | MSG_FS_INDEX_LIST_GET MsgType = 131 // Request from client for list of indexed files. | ||
172 | MSG_FS_INDEX_LIST_ENTRY MsgType = 132 // Reply to client with an indexed file name. | ||
173 | MSG_FS_INDEX_LIST_END MsgType = 133 // Reply to client indicating end of list. | ||
174 | MSG_FS_UNINDEX MsgType = 134 // Request from client to unindex a file. | ||
175 | MSG_FS_UNINDEX_OK MsgType = 135 // Reply to client indicating unindex receipt. | ||
176 | MSG_FS_START_SEARCH MsgType = 136 // Client asks FS service to start a (keyword) search. | ||
177 | MSG_FS_GET MsgType = 137 // P2P request for content (one FS to another). | ||
178 | 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). | ||
179 | MSG_FS_MIGRATION_STOP MsgType = 139 // Peer asks us to stop migrating content towards it for a while. | ||
180 | MSG_FS_CADET_QUERY MsgType = 140 // P2P request for content (one FS to another via a cadet). | ||
181 | MSG_FS_CADET_REPLY MsgType = 141 // P2P answer for content (one FS to another via a cadet). | ||
182 | |||
183 | //------------------------------------------------------------------ | ||
184 | // DHT message types | ||
185 | //------------------------------------------------------------------ | ||
186 | |||
187 | MSG_DHT_CLIENT_PUT MsgType = 142 // Client wants to store item in DHT. | ||
188 | MSG_DHT_CLIENT_GET MsgType = 143 // Client wants to lookup item in DHT. | ||
189 | MSG_DHT_CLIENT_GET_STOP MsgType = 144 // Client wants to stop search in DHT. | ||
190 | MSG_DHT_CLIENT_RESULT MsgType = 145 // Service returns result to client. | ||
191 | MSG_DHT_P2P_PUT MsgType = 146 // Peer is storing data in DHT. | ||
192 | MSG_DHT_P2P_GET MsgType = 147 // Peer tries to find data in DHT. | ||
193 | MSG_DHT_P2P_RESULT MsgType = 148 // Data is returned to peer from DHT. | ||
194 | MSG_DHT_MONITOR_GET MsgType = 149 // Receive information about transiting GETs | ||
195 | MSG_DHT_MONITOR_GET_RESP MsgType = 150 // Receive information about transiting GET responses | ||
196 | MSG_DHT_MONITOR_PUT MsgType = 151 // Receive information about transiting PUTs | ||
197 | MSG_DHT_MONITOR_PUT_RESP MsgType = 152 // Receive information about transiting PUT responses (TODO) | ||
198 | MSG_DHT_MONITOR_START MsgType = 153 // Request information about transiting messages | ||
199 | MSG_DHT_MONITOR_STOP MsgType = 154 // Stop information about transiting messages | ||
200 | MSG_DHT_CLIENT_GET_RESULTS_KNOWN MsgType = 156 // Certain results are already known to the client, filter those. | ||
201 | MSG_DHT_P2P_HELLO MsgType = 157 // HELLO advertising a neighbours addresses. | ||
202 | MSG_DHT_CORE MsgType = 158 // Encapsulation of DHT messages in CORE service. | ||
203 | MSG_DHT_CLIENT_HELLO_URL MsgType = 159 // HELLO URL send between client and service (in either direction). | ||
204 | MSG_DHT_CLIENT_HELLO_GET MsgType = 161 // Client requests DHT service's HELLO URL. | ||
205 | |||
206 | //------------------------------------------------------------------ | ||
207 | // HOSTLIST message types | ||
208 | //------------------------------------------------------------------ | ||
209 | |||
210 | MSG_HOSTLIST_ADVERTISEMENT MsgType = 160 // Hostlist advertisement message | ||
211 | |||
212 | //------------------------------------------------------------------ | ||
213 | // STATISTICS message types | ||
214 | //------------------------------------------------------------------ | ||
215 | |||
216 | MSG_STATISTICS_SET MsgType = 168 // Set a statistical value. | ||
217 | MSG_STATISTICS_GET MsgType = 169 // Get a statistical value(s). | ||
218 | MSG_STATISTICS_VALUE MsgType = 170 // Response to a STATISTICS_GET message (with value). | ||
219 | MSG_STATISTICS_END MsgType = 171 // Response to a STATISTICS_GET message (end of value stream). | ||
220 | 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. | ||
221 | MSG_STATISTICS_WATCH_VALUE MsgType = 173 // Changes to a watched value. | ||
222 | MSG_STATISTICS_DISCONNECT MsgType = 174 // Client is done sending service requests and will now disconnect. | ||
223 | MSG_STATISTICS_DISCONNECT_CONFIRM MsgType = 175 // Service confirms disconnect and that it is done processing all requests from the client. | ||
224 | |||
225 | //------------------------------------------------------------------ | ||
226 | // VPN message types | ||
227 | //------------------------------------------------------------------ | ||
228 | |||
229 | MSG_VPN_HELPER MsgType = 185 // Type of messages between the gnunet-vpn-helper and the daemon | ||
230 | MSG_VPN_ICMP_TO_SERVICE MsgType = 190 // ICMP packet for a service. | ||
231 | MSG_VPN_ICMP_TO_INTERNET MsgType = 191 // ICMP packet for the Internet. | ||
232 | MSG_VPN_ICMP_TO_VPN MsgType = 192 // ICMP packet for the VPN | ||
233 | MSG_VPN_DNS_TO_INTERNET MsgType = 193 // DNS request for a DNS exit service. | ||
234 | MSG_VPN_DNS_FROM_INTERNET MsgType = 194 // DNS reply from a DNS exit service. | ||
235 | MSG_VPN_TCP_TO_SERVICE_START MsgType = 195 // TCP packet for a service. | ||
236 | MSG_VPN_TCP_TO_INTERNET_START MsgType = 196 // TCP packet for the Internet. | ||
237 | MSG_VPN_TCP_DATA_TO_EXIT MsgType = 197 // TCP packet of an established connection. | ||
238 | MSG_VPN_TCP_DATA_TO_VPN MsgType = 198 // TCP packet of an established connection. | ||
239 | MSG_VPN_UDP_TO_SERVICE MsgType = 199 // UDP packet for a service. | ||
240 | MSG_VPN_UDP_TO_INTERNET MsgType = 200 // UDP packet for the Internet. | ||
241 | MSG_VPN_UDP_REPLY MsgType = 201 // UDP packet from a remote host | ||
242 | 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. | ||
243 | 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. | ||
244 | MSG_VPN_CLIENT_USE_IP MsgType = 204 // VPN service responds to client with an IP to use for the requested redirection. | ||
245 | |||
246 | //------------------------------------------------------------------ | ||
247 | // VPN-DNS message types | ||
248 | //------------------------------------------------------------------ | ||
249 | |||
250 | MSG_DNS_CLIENT_INIT MsgType = 211 // Initial message from client to DNS service for registration. | ||
251 | MSG_DNS_CLIENT_REQUEST MsgType = 212 // Type of messages between the gnunet-helper-dns and the service | ||
252 | MSG_DNS_CLIENT_RESPONSE MsgType = 213 // Type of messages between the gnunet-helper-dns and the service | ||
253 | MSG_DNS_HELPER MsgType = 214 // Type of messages between the gnunet-helper-dns and the service | ||
254 | |||
255 | //------------------------------------------------------------------ | ||
256 | // CHAT message types START | ||
257 | //------------------------------------------------------------------ | ||
258 | |||
259 | MSG_CHAT_JOIN_REQUEST MsgType = 300 // Message sent from client to join a chat room. | ||
260 | MSG_CHAT_JOIN_NOTIFICATION MsgType = 301 // Message sent to client to indicate joining of another room member. | ||
261 | MSG_CHAT_LEAVE_NOTIFICATION MsgType = 302 // Message sent to client to indicate leaving of another room member. | ||
262 | MSG_CHAT_MESSAGE_NOTIFICATION MsgType = 303 // Notification sent by service to client indicating that we've received a chat message. | ||
263 | MSG_CHAT_TRANSMIT_REQUEST MsgType = 304 // Request sent by client to transmit a chat message to another room members. | ||
264 | MSG_CHAT_CONFIRMATION_RECEIPT MsgType = 305 // Receipt sent from a message receiver to the service to confirm delivery of a chat message. | ||
265 | MSG_CHAT_CONFIRMATION_NOTIFICATION MsgType = 306 // Notification sent from the service to the original sender to acknowledge delivery of a chat message. | ||
266 | MSG_CHAT_P2P_JOIN_NOTIFICATION MsgType = 307 // P2P message sent to indicate joining of another room member. | ||
267 | MSG_CHAT_P2P_LEAVE_NOTIFICATION MsgType = 308 // P2P message sent to indicate leaving of another room member. | ||
268 | 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. | ||
269 | MSG_CHAT_P2P_MESSAGE_NOTIFICATION MsgType = 310 // Notification sent from one peer to another to indicate that we have received a chat message. | ||
270 | MSG_CHAT_P2P_CONFIRMATION_RECEIPT MsgType = 311 // P2P receipt confirming delivery of a chat message. | ||
271 | |||
272 | //------------------------------------------------------------------ | ||
273 | // NSE (network size estimation) message types | ||
274 | //------------------------------------------------------------------ | ||
275 | |||
276 | MSG_NSE_START MsgType = 321 // client->service message indicating start | ||
277 | MSG_NSE_P2P_FLOOD MsgType = 322 // P2P message sent from nearest peer | ||
278 | MSG_NSE_ESTIMATE MsgType = 323 // service->client message indicating | ||
279 | |||
280 | //------------------------------------------------------------------ | ||
281 | // PEERINFO message types | ||
282 | //------------------------------------------------------------------ | ||
283 | |||
284 | MSG_PEERINFO_GET MsgType = 330 // Request update and listing of a peer | ||
285 | MSG_PEERINFO_GET_ALL MsgType = 331 // Request update and listing of all peers | ||
286 | MSG_PEERINFO_INFO MsgType = 332 // Information about one of the peers | ||
287 | MSG_PEERINFO_INFO_END MsgType = 333 // End of information about other peers | ||
288 | MSG_PEERINFO_NOTIFY MsgType = 334 // Start notifying this client about changes | ||
289 | |||
290 | //------------------------------------------------------------------ | ||
291 | // ATS message types | ||
292 | //------------------------------------------------------------------ | ||
293 | |||
294 | MSG_ATS_START MsgType = 340 // Type of the 'struct ClientStartMessage' sent by clients to ATS to identify the type of the client. | ||
295 | MSG_ATS_REQUEST_ADDRESS MsgType = 341 // Type of the 'struct RequestAddressMessage' sent by clients to request an address to help connect. | ||
296 | MSG_ATS_REQUEST_ADDRESS_CANCEL MsgType = 342 // Type of the 'struct RequestAddressMessage' sent by clients to request an address to help connect. | ||
297 | MSG_ATS_ADDRESS_UPDATE MsgType = 343 // Type of the 'struct AddressUpdateMessage' sent by clients to ATS to inform ATS about performance changes. | ||
298 | MSG_ATS_ADDRESS_DESTROYED MsgType = 344 // Type of the 'struct AddressDestroyedMessage' sent by clients to ATS to inform ATS about an address being unavailable. | ||
299 | MSG_ATS_ADDRESS_SUGGESTION MsgType = 345 // Type of the 'struct AddressSuggestionMessage' sent by ATS to clients to suggest switching to a different address. | ||
300 | MSG_ATS_PEER_INFORMATION MsgType = 346 // Type of the 'struct PeerInformationMessage' sent by ATS to clients to inform about QoS for a particular connection. | ||
301 | MSG_ATS_RESERVATION_REQUEST MsgType = 347 // Type of the 'struct ReservationRequestMessage' sent by clients to ATS to ask for inbound bandwidth reservations. | ||
302 | MSG_ATS_RESERVATION_RESULT MsgType = 348 // Type of the 'struct ReservationResultMessage' sent by ATS to clients in response to a reservation request. | ||
303 | MSG_ATS_PREFERENCE_CHANGE MsgType = 349 // Type of the 'struct ChangePreferenceMessage' sent by clients to ATS to ask for allocation preference changes. | ||
304 | MSG_ATS_SESSION_RELEASE MsgType = 350 // Type of the 'struct SessionReleaseMessage' sent by ATS to client to confirm that a session ID was destroyed. | ||
305 | MSG_ATS_ADDRESS_ADD MsgType = 353 // Type of the 'struct AddressUpdateMessage' sent by client to ATS to add a new address | ||
306 | MSG_ATS_ADDRESSLIST_REQUEST MsgType = 354 // Type of the 'struct AddressListRequestMessage' sent by client to ATS to request information about addresses | ||
307 | MSG_ATS_ADDRESSLIST_RESPONSE MsgType = 355 // Type of the 'struct AddressListResponseMessage' sent by ATS to client with information about addresses | ||
308 | MSG_ATS_PREFERENCE_FEEDBACK MsgType = 356 // Type of the 'struct ChangePreferenceMessage' sent by clients to ATS to ask for allocation preference changes. | ||
309 | |||
310 | //------------------------------------------------------------------ | ||
311 | // TRANSPORT message types | ||
312 | //------------------------------------------------------------------ | ||
313 | |||
314 | 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. | ||
315 | MSG_TRANSPORT_CONNECT MsgType = 361 // Message from TRANSPORT notifying about a client that connected to us. | ||
316 | MSG_TRANSPORT_DISCONNECT MsgType = 362 // Message from TRANSPORT notifying about a client that disconnected from us. | ||
317 | MSG_TRANSPORT_SEND MsgType = 363 // Request to TRANSPORT to transmit a message. | ||
318 | 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. | ||
319 | MSG_TRANSPORT_RECV MsgType = 365 // Message from TRANSPORT notifying about a message that was received. | ||
320 | MSG_TRANSPORT_SET_QUOTA MsgType = 366 // Message telling transport to limit its receive rate. | ||
321 | MSG_TRANSPORT_ADDRESS_TO_STRING MsgType = 367 // Request to look addresses of peers in server. | ||
322 | MSG_TRANSPORT_ADDRESS_TO_STRING_REPLY MsgType = 368 // Response to the address lookup request. | ||
323 | MSG_TRANSPORT_BLACKLIST_INIT MsgType = 369 // Register a client that wants to do blacklisting. | ||
324 | MSG_TRANSPORT_BLACKLIST_QUERY MsgType = 370 // Query to a blacklisting client (is this peer blacklisted)? | ||
325 | MSG_TRANSPORT_BLACKLIST_REPLY MsgType = 371 // Reply from blacklisting client (answer to blacklist query). | ||
326 | MSG_TRANSPORT_PING MsgType = 372 // Transport PING message | ||
327 | MSG_TRANSPORT_PONG MsgType = 373 // Transport PONG message | ||
328 | MSG_TRANSPORT_SESSION_SYN MsgType = 375 // Transport SYN message exchanged between transport services to indicate that a session should be marked as 'connected'. | ||
329 | MSG_TRANSPORT_SESSION_SYN_ACK MsgType = 376 // Transport SYN_ACK message exchanged between transport services to indicate that a SYN message was accepted | ||
330 | MSG_TRANSPORT_SESSION_ACK MsgType = 377 // Transport ACK message exchanged between transport services to indicate that a SYN_ACK message was accepted | ||
331 | MSG_TRANSPORT_SESSION_DISCONNECT MsgType = 378 // Transport DISCONNECT message exchanged between transport services to indicate that a connection should be dropped. | ||
332 | 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. | ||
333 | MSG_TRANSPORT_MONITOR_PEER_REQUEST MsgType = 380 // Request to monitor addresses used by a peer or all peers. | ||
334 | 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 | ||
335 | MSG_TRANSPORT_SESSION_KEEPALIVE_RESPONSE MsgType = 382 // Response to a #TRANSPORT_SESSION_KEEPALIVE message to measure latency in a regular interval | ||
336 | MSG_TRANSPORT_MONITOR_PEER_RESPONSE MsgType = 383 // Response to #TRANSPORT_MONITOR_PEER_REQUEST request to iterate over all known addresses. | ||
337 | MSG_TRANSPORT_BROADCAST_BEACON MsgType = 384 // Message send by a peer to notify the other to keep the session alive. | ||
338 | MSG_TRANSPORT_TRAFFIC_METRIC MsgType = 385 // Message containing traffic metrics for transport service | ||
339 | MSG_TRANSPORT_MONITOR_PLUGIN_START MsgType = 388 // Request to start monitoring the connection state of plugins. | ||
340 | 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 | ||
341 | 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. | ||
342 | MSG_TRANSPORT_MONITOR_PEER_RESPONSE_END MsgType = 391 // terminating list of replies. | ||
343 | |||
344 | //------------------------------------------------------------------ | ||
345 | // FS-PUBLISH-HELPER IPC Messages | ||
346 | //------------------------------------------------------------------ | ||
347 | |||
348 | MSG_FS_PUBLISH_HELPER_PROGRESS_FILE MsgType = 420 // Progress information from the helper: found a file | ||
349 | MSG_FS_PUBLISH_HELPER_PROGRESS_DIRECTORY MsgType = 421 // Progress information from the helper: found a directory | ||
350 | MSG_FS_PUBLISH_HELPER_ERROR MsgType = 422 // Error signal from the helper. | ||
351 | MSG_FS_PUBLISH_HELPER_SKIP_FILE MsgType = 423 // Signal that helper skipped a file. | ||
352 | MSG_FS_PUBLISH_HELPER_COUNTING_DONE MsgType = 424 // Signal that helper is done scanning the directory tree. | ||
353 | MSG_FS_PUBLISH_HELPER_META_DATA MsgType = 425 // Extracted meta data from the helper. | ||
354 | MSG_FS_PUBLISH_HELPER_FINISHED MsgType = 426 // Signal that helper is done. | ||
355 | |||
356 | //------------------------------------------------------------------ | ||
357 | // NAMECACHE message types | ||
358 | //------------------------------------------------------------------ | ||
359 | |||
360 | MSG_NAMECACHE_LOOKUP_BLOCK MsgType = 431 // Client to service: lookup block | ||
361 | MSG_NAMECACHE_LOOKUP_BLOCK_RESPONSE MsgType = 432 // Service to client: result of block lookup | ||
362 | MSG_NAMECACHE_BLOCK_CACHE MsgType = 433 // Client to service: cache a block | ||
363 | MSG_NAMECACHE_BLOCK_CACHE_RESPONSE MsgType = 434 // Service to client: result of block cache request | ||
364 | |||
365 | //------------------------------------------------------------------ | ||
366 | // NAMESTORE message types | ||
367 | //------------------------------------------------------------------ | ||
368 | |||
369 | MSG_NAMESTORE_RECORD_STORE MsgType = 435 // Client to service: store records (as authority) | ||
370 | MSG_NAMESTORE_RECORD_STORE_RESPONSE MsgType = 436 // Service to client: result of store operation. | ||
371 | MSG_NAMESTORE_RECORD_LOOKUP MsgType = 437 // Client to service: lookup label | ||
372 | MSG_NAMESTORE_RECORD_LOOKUP_RESPONSE MsgType = 438 // Service to client: lookup label | ||
373 | MSG_NAMESTORE_ZONE_TO_NAME MsgType = 439 // Client to service: "reverse" lookup for zone name based on zone key | ||
374 | MSG_NAMESTORE_ZONE_TO_NAME_RESPONSE MsgType = 440 // Service to client: result of zone-to-name lookup. | ||
375 | MSG_NAMESTORE_MONITOR_START MsgType = 441 // Client to service: start monitoring (yields sequence of "ZONE_ITERATION_RESPONSES" --- forever). | ||
376 | MSG_NAMESTORE_MONITOR_SYNC MsgType = 442 // Service to client: you're now in sync. | ||
377 | MSG_NAMESTORE_RECORD_RESULT MsgType = 443 // Service to client: here is a (plaintext) record you requested. | ||
378 | 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. | ||
379 | MSG_NAMESTORE_ZONE_ITERATION_START MsgType = 445 // Client to service: please start iteration; receives "NAMESTORE_LOOKUP_NAME_RESPONSE" messages in return. | ||
380 | MSG_NAMESTORE_ZONE_ITERATION_NEXT MsgType = 447 // Client to service: next record(s) in iteration please. | ||
381 | MSG_NAMESTORE_ZONE_ITERATION_STOP MsgType = 448 // Client to service: stop iterating. | ||
382 | |||
383 | //------------------------------------------------------------------ | ||
384 | // LOCKMANAGER message types | ||
385 | //------------------------------------------------------------------ | ||
386 | |||
387 | MSG_LOCKMANAGER_ACQUIREMsgType = 450 // Message to acquire Lock | ||
388 | MSG_LOCKMANAGER_RELEASEMsgType = 451 // Message to release lock | ||
389 | MSG_LOCKMANAGER_SUCCESSMsgType = 452 // SUCCESS reply from lockmanager | ||
390 | |||
391 | //------------------------------------------------------------------ | ||
392 | // TESTBED message types | ||
393 | //------------------------------------------------------------------ | ||
394 | |||
395 | MSG_TESTBED_INIT MsgType = 460 // Initial message from a client to a testing control service | ||
396 | MSG_TESTBED_ADD_HOST MsgType = 461 // Message to add host | ||
397 | MSG_TESTBED_ADD_HOST_SUCCESS MsgType = 462 // Message to signal that a add host succeeded | ||
398 | MSG_TESTBED_LINK_CONTROLLERS MsgType = 463 // Message to link delegated controller to slave controller | ||
399 | MSG_TESTBED_CREATE_PEER MsgType = 464 // Message to create a peer at a host | ||
400 | MSG_TESTBED_RECONFIGURE_PEER MsgType = 465 // Message to reconfigure a peer | ||
401 | MSG_TESTBED_START_PEER MsgType = 466 // Message to start a peer at a host | ||
402 | MSG_TESTBED_STOP_PEER MsgType = 467 // Message to stop a peer at a host | ||
403 | MSG_TESTBED_DESTROY_PEER MsgType = 468 // Message to destroy a peer | ||
404 | MSG_TESTBED_CONFIGURE_UNDERLAY_LINK MsgType = 469 // Configure underlay link message | ||
405 | MSG_TESTBED_OVERLAY_CONNECT MsgType = 470 // Message to connect peers in a overlay | ||
406 | MSG_TESTBED_PEER_EVENT MsgType = 471 // Message for peer events | ||
407 | MSG_TESTBED_PEER_CONNECT_EVENT MsgType = 472 // Message for peer connect events | ||
408 | MSG_TESTBED_OPERATION_FAIL_EVENT MsgType = 473 // Message for operation events | ||
409 | MSG_TESTBED_CREATE_PEER_SUCCESS MsgType = 474 // Message to signal successful peer creation | ||
410 | MSG_TESTBED_GENERIC_OPERATION_SUCCESS MsgType = 475 // Message to signal a generic operation has been successful | ||
411 | MSG_TESTBED_GET_PEER_INFORMATION MsgType = 476 // Message to get a peer's information | ||
412 | MSG_TESTBED_PEER_INFORMATION MsgType = 477 // Message containing the peer's information | ||
413 | 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 | ||
414 | MSG_TESTBED_GET_SLAVE_CONFIGURATION MsgType = 479 // Message to request configuration of a slave controller | ||
415 | MSG_TESTBED_SLAVE_CONFIGURATION MsgType = 480 // Message which contains the configuration of slave controller | ||
416 | MSG_TESTBED_LINK_CONTROLLERS_RESULT MsgType = 481 // Message to signal the result of #TESTBED_LINK_CONTROLLERS request | ||
417 | 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 | ||
418 | MSG_TESTBED_MANAGE_PEER_SERVICE MsgType = 483 // Message to start/stop a service of a peer | ||
419 | MSG_TESTBED_BARRIER_INIT MsgType = 484 // Message to initialise a barrier. Messages of these type are flooded to all sub-controllers | ||
420 | MSG_TESTBED_BARRIER_CANCEL MsgType = 485 // Message to cancel a barrier. This message is flooded to all sub-controllers | ||
421 | MSG_TESTBED_BARRIER_STATUS MsgType = 486 // Message for signalling status of a barrier | ||
422 | 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 | ||
423 | 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 | ||
424 | MSG_TESTBED_HELPER_INIT MsgType = 495 // The initialization message towards gnunet-testbed-helper | ||
425 | MSG_TESTBED_HELPER_REPLY MsgType = 496 // The reply message from gnunet-testbed-helper | ||
426 | |||
427 | //------------------------------------------------------------------ | ||
428 | // GNS. | ||
429 | //------------------------------------------------------------------ | ||
430 | |||
431 | MSG_GNS_LOOKUP MsgType = 500 // Client would like to resolve a name. | ||
432 | MSG_GNS_LOOKUP_RESULT MsgType = 501 // Service response to name resolution request from client. | ||
433 | MSG_GNS_REVERSE_LOOKUP MsgType = 502 // Reverse lookup | ||
434 | MSG_GNS_REVERSE_LOOKUP_RESULT MsgType = 503 // Response to reverse lookup | ||
435 | |||
436 | //------------------------------------------------------------------ | ||
437 | // CONSENSUS message types | ||
438 | //------------------------------------------------------------------ | ||
439 | |||
440 | MSG_CONSENSUS_CLIENT_JOIN MsgType = 520 // Join a consensus session. Sent by client to service as first message. | ||
441 | MSG_CONSENSUS_CLIENT_INSERT MsgType = 521 // Insert an element. Sent by client to service. | ||
442 | MSG_CONSENSUS_CLIENT_BEGIN MsgType = 522 // Begin accepting new elements from other participants. Sent by client to service. | ||
443 | MSG_CONSENSUS_CLIENT_RECEIVED_ELEMENT MsgType = 523 // Sent by service when a new element is added. | ||
444 | MSG_CONSENSUS_CLIENT_CONCLUDE MsgType = 524 // Sent by client to service in order to start the consensus conclusion. | ||
445 | 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. | ||
446 | MSG_CONSENSUS_CLIENT_ACK MsgType = 540 // Sent by client to service, telling whether a received element should be accepted and propagated further or not. | ||
447 | MSG_CONSENSUS_P2P_DELTA_ESTIMATE MsgType = 541 // Strata estimator. | ||
448 | MSG_CONSENSUS_P2P_DIFFERENCE_DIGEST MsgType = 542 // IBF containing all elements of a peer. | ||
449 | MSG_CONSENSUS_P2P_ELEMENTS MsgType = 543 // One or more elements that are sent from peer to peer. | ||
450 | MSG_CONSENSUS_P2P_ELEMENTS_REQUEST MsgType = 544 // Elements, and requests for further elements | ||
451 | MSG_CONSENSUS_P2P_ELEMENTS_REPORT MsgType = 545 // Elements that a peer reports to be missing at the remote peer. | ||
452 | MSG_CONSENSUS_P2P_HELLO MsgType = 546 // Initialization message for consensus p2p communication. | ||
453 | MSG_CONSENSUS_P2P_SYNCED MsgType = 547 // Report that the peer is synced with the partner after successfully decoding the invertible bloom filter. | ||
454 | MSG_CONSENSUS_P2P_FIN MsgType = 548 // Interaction os over, got synched and reported all elements | ||
455 | MSG_CONSENSUS_P2P_ABORT MsgType = 548 // Abort a round, don't send requested elements anymore | ||
456 | MSG_CONSENSUS_P2P_ROUND_CONTEXT MsgType = 547 // Abort a round, don't send requested elements anymore | ||
457 | |||
458 | //------------------------------------------------------------------ | ||
459 | // SET message types | ||
460 | //------------------------------------------------------------------ | ||
461 | |||
462 | MSG_SET_UNION_P2P_REQUEST_FULL MsgType = 565 // Demand the whole element from the other peer, given only the hash code. | ||
463 | MSG_SET_UNION_P2P_DEMAND MsgType = 566 // Demand the whole element from the other peer, given only the hash code. | ||
464 | MSG_SET_UNION_P2P_INQUIRY MsgType = 567 // Tell the other peer to send us a list of hashes that match an IBF key. | ||
465 | MSG_SET_UNION_P2P_OFFER MsgType = 568 // Tell the other peer which hashes match a given IBF key. | ||
466 | MSG_SET_REJECT MsgType = 569 // Reject a set request. | ||
467 | MSG_SET_CANCEL MsgType = 570 // Cancel a set operation | ||
468 | MSG_SET_ITER_ACK MsgType = 571 // Acknowledge result from iteration | ||
469 | MSG_SET_RESULT MsgType = 572 // Create an empty set | ||
470 | MSG_SET_ADD MsgType = 573 // Add element to set | ||
471 | MSG_SET_REMOVE MsgType = 574 // Remove element from set | ||
472 | MSG_SET_LISTEN MsgType = 575 // Listen for operation requests | ||
473 | MSG_SET_ACCEPT MsgType = 576 // Accept a set request | ||
474 | MSG_SET_EVALUATE MsgType = 577 // Evaluate a set operation | ||
475 | MSG_SET_CONCLUDE MsgType = 578 // Start a set operation with the given set | ||
476 | MSG_SET_REQUEST MsgType = 579 // Notify the client of a request from a remote peer | ||
477 | MSG_SET_CREATE MsgType = 580 // Create a new local set | ||
478 | MSG_SET_P2P_OPERATION_REQUEST MsgType = 581 // Request a set operation from a remote peer. | ||
479 | MSG_SET_UNION_P2P_SE MsgType = 582 // Strata estimator. | ||
480 | MSG_SET_UNION_P2P_IBF MsgType = 583 // Invertible bloom filter. | ||
481 | MSG_SET_P2P_ELEMENTS MsgType = 584 // Actual set elements. | ||
482 | MSG_SET_P2P_ELEMENT_REQUESTS MsgType = 585 // Requests for the elements with the given hashes. | ||
483 | MSG_SET_UNION_P2P_DONE MsgType = 586 // Set operation is done. | ||
484 | MSG_SET_ITER_REQUEST MsgType = 587 // Start iteration over set elements. | ||
485 | MSG_SET_ITER_ELEMENT MsgType = 588 // Element result for the iterating client. | ||
486 | MSG_SET_ITER_DONE MsgType = 589 // Iteration end marker for the client. | ||
487 | MSG_SET_UNION_P2P_SEC MsgType = 590 // Compressed strata estimator. | ||
488 | MSG_SET_INTERSECTION_P2P_ELEMENT_INFO MsgType = 591 // Information about the element count for intersection | ||
489 | MSG_SET_INTERSECTION_P2P_BF MsgType = 592 // Bloom filter message for intersection exchange started by Bob. | ||
490 | MSG_SET_INTERSECTION_P2P_DONE MsgType = 593 // Intersection operation is done. | ||
491 | MSG_SET_COPY_LAZY_PREPARE MsgType = 594 // Ask the set service to prepare a copy of a set. | ||
492 | MSG_SET_COPY_LAZY_RESPONSE MsgType = 595 // Give the client an ID for connecting to the set's copy. | ||
493 | MSG_SET_COPY_LAZY_CONNECT MsgType = 596 // Sent by the client to the server to connect to an existing, lazily copied set. | ||
494 | 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. | ||
495 | 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. | ||
496 | 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. | ||
497 | |||
498 | //------------------------------------------------------------------ | ||
499 | // TESTBED LOGGER message types | ||
500 | //------------------------------------------------------------------ | ||
501 | |||
502 | MSG_TESTBED_LOGGER_MSG MsgType = 600 // Message for TESTBED LOGGER | ||
503 | MSG_TESTBED_LOGGER_ACK MsgType = 601 // Message for TESTBED LOGGER acknowledgement | ||
504 | |||
505 | MSG_REGEX_ANNOUNCE MsgType = 620 // Advertise regex capability. | ||
506 | MSG_REGEX_SEARCH MsgType = 621 // Search for peer with matching capability. | ||
507 | MSG_REGEX_RESULT MsgType = 622 // Result in response to regex search. | ||
508 | |||
509 | //------------------------------------------------------------------ | ||
510 | // IDENTITY message types | ||
511 | //------------------------------------------------------------------ | ||
512 | |||
513 | MSG_IDENTITY_START MsgType = 624 // First message send from identity client to service (to subscribe to updates). | ||
514 | MSG_IDENTITY_RESULT_CODE MsgType = 625 // Generic response from identity service with success and/or error message. | ||
515 | MSG_IDENTITY_UPDATE MsgType = 626 // Update about identity status from service to clients. | ||
516 | MSG_IDENTITY_GET_DEFAULT MsgType = 627 // Client requests to know default identity for a subsystem. | ||
517 | MSG_IDENTITY_SET_DEFAULT MsgType = 628 // Client sets default identity; or service informs about default identity. | ||
518 | MSG_IDENTITY_CREATE MsgType = 629 // Create new identity (client->service). | ||
519 | MSG_IDENTITY_RENAME MsgType = 630 // Rename existing identity (client->service). | ||
520 | MSG_IDENTITY_DELETE MsgType = 631 // Delete identity (client->service). | ||
521 | MSG_IDENTITY_LOOKUP MsgType = 632 | ||
522 | MSG_IDENTITY_LOOKUP_BY_NAME MsgType = 633 | ||
523 | |||
524 | //------------------------------------------------------------------ | ||
525 | // REVOCATION message types | ||
526 | //------------------------------------------------------------------ | ||
527 | |||
528 | MSG_REVOCATION_QUERY MsgType = 636 // Client to service: was this key revoked? | ||
529 | MSG_REVOCATION_QUERY_RESPONSE MsgType = 637 // Service to client: answer if key was revoked! | ||
530 | MSG_REVOCATION_REVOKE MsgType = 638 // Client to service OR peer-to-peer: revoke this key! | ||
531 | MSG_REVOCATION_REVOKE_RESPONSE MsgType = 639 // Service to client: revocation confirmed | ||
532 | |||
533 | //------------------------------------------------------------------ | ||
534 | // SCALARPRODUCT message types | ||
535 | //------------------------------------------------------------------ | ||
536 | |||
537 | MSG_SCALARPRODUCT_CLIENT_TO_ALICE MsgType = 640 // Client -> Alice | ||
538 | MSG_SCALARPRODUCT_CLIENT_TO_BOB MsgType = 641 // Client -> Bob | ||
539 | MSG_SCALARPRODUCT_CLIENT_MULTIPART_ALICE MsgType = 642 // Client -> Alice multipart | ||
540 | MSG_SCALARPRODUCT_CLIENT_MULTIPART_BOB MsgType = 643 // Client -> Bob multipart | ||
541 | MSG_SCALARPRODUCT_SESSION_INITIALIZATION MsgType = 644 // Alice -> Bob session initialization | ||
542 | MSG_SCALARPRODUCT_ALICE_CRYPTODATA MsgType = 645 // Alice -> Bob SP crypto-data (after intersection) | ||
543 | MSG_SCALARPRODUCT_BOB_CRYPTODATA MsgType = 647 // Bob -> Alice SP crypto-data | ||
544 | MSG_SCALARPRODUCT_BOB_CRYPTODATA_MULTIPART MsgType = 648 // Bob -> Alice SP crypto-data multipart | ||
545 | MSG_SCALARPRODUCT_RESULT MsgType = 649 // Alice/Bob -> Client Result | ||
546 | MSG_SCALARPRODUCT_ECC_SESSION_INITIALIZATION MsgType = 650 // Alice -> Bob ECC session initialization | ||
547 | MSG_SCALARPRODUCT_ECC_ALICE_CRYPTODATA MsgType = 651 // Alice -> Bob ECC crypto data | ||
548 | MSG_SCALARPRODUCT_ECC_BOB_CRYPTODATA MsgType = 652 // Bob -> Alice ECC crypto data | ||
549 | |||
550 | //------------------------------------------------------------------ | ||
551 | // PSYCSTORE message types | ||
552 | //------------------------------------------------------------------ | ||
553 | |||
554 | MSG_PSYCSTORE_MEMBERSHIP_STORE MsgType = 660 // Store a membership event. | ||
555 | MSG_PSYCSTORE_MEMBERSHIP_TEST MsgType = 661 // Test for membership of a member at a particular point in time. | ||
556 | MSG_PSYCSTORE_FRAGMENT_STORE MsgType = 662 // | ||
557 | MSG_PSYCSTORE_FRAGMENT_GET MsgType = 663 // | ||
558 | MSG_PSYCSTORE_MESSAGE_GET MsgType = 664 // | ||
559 | MSG_PSYCSTORE_MESSAGE_GET_FRAGMENT MsgType = 665 // | ||
560 | MSG_PSYCSTORE_COUNTERS_GET MsgType = 666 // | ||
561 | MSG_PSYCSTORE_STATE_MODIFY MsgType = 668 // | ||
562 | MSG_PSYCSTORE_STATE_SYNC MsgType = 669 // | ||
563 | MSG_PSYCSTORE_STATE_RESET MsgType = 670 // | ||
564 | MSG_PSYCSTORE_STATE_HASH_UPDATE MsgType = 671 // | ||
565 | MSG_PSYCSTORE_STATE_GET MsgType = 672 // | ||
566 | MSG_PSYCSTORE_STATE_GET_PREFIX MsgType = 673 // | ||
567 | MSG_PSYCSTORE_RESULT_CODE MsgType = 674 // Generic response from PSYCstore service with success and/or error message. | ||
568 | MSG_PSYCSTORE_RESULT_FRAGMENT MsgType = 675 // | ||
569 | MSG_PSYCSTORE_RESULT_COUNTERS MsgType = 676 // | ||
570 | MSG_PSYCSTORE_RESULT_STATE MsgType = 677 // | ||
571 | |||
572 | //------------------------------------------------------------------ | ||
573 | // PSYC message types | ||
574 | //------------------------------------------------------------------ | ||
575 | |||
576 | MSG_PSYC_RESULT_CODE MsgType = 680 // S->C: result of an operation | ||
577 | MSG_PSYC_MASTER_START MsgType = 681 // C->S: request to start a channel as a master | ||
578 | MSG_PSYC_MASTER_START_ACK MsgType = 682 // S->C: master start acknowledgement | ||
579 | MSG_PSYC_SLAVE_JOIN MsgType = 683 // C->S: request to join a channel as a slave | ||
580 | MSG_PSYC_SLAVE_JOIN_ACK MsgType = 684 // S->C: slave join acknowledgement | ||
581 | MSG_PSYC_PART_REQUEST MsgType = 685 // C->S: request to part from a channel | ||
582 | MSG_PSYC_PART_ACK MsgType = 686 // S->C: acknowledgement that a slave of master parted from a channel | ||
583 | MSG_PSYC_JOIN_REQUEST MsgType = 687 // M->S->C: incoming join request from multicast | ||
584 | MSG_PSYC_JOIN_DECISION MsgType = 688 // C->S->M: decision about a join request | ||
585 | MSG_PSYC_CHANNEL_MEMBERSHIP_STORE MsgType = 689 // C->S: request to add/remove channel slave in the membership database. | ||
586 | MSG_PSYC_MESSAGE MsgType = 691 // S<--C: PSYC message which contains one or more message parts. | ||
587 | MSG_PSYC_MESSAGE_HEADER MsgType = 692 // M<->S<->C: PSYC message which contains a header and one or more message parts. | ||
588 | MSG_PSYC_MESSAGE_METHOD MsgType = 693 // Message part: method | ||
589 | MSG_PSYC_MESSAGE_MODIFIER MsgType = 694 // Message part: modifier | ||
590 | MSG_PSYC_MESSAGE_MOD_CONT MsgType = 695 // Message part: modifier continuation | ||
591 | MSG_PSYC_MESSAGE_DATA MsgType = 696 // Message part: data | ||
592 | MSG_PSYC_MESSAGE_END MsgType = 697 // Message part: end of message | ||
593 | MSG_PSYC_MESSAGE_CANCEL MsgType = 698 // Message part: message cancelled | ||
594 | MSG_PSYC_MESSAGE_ACK MsgType = 699 // S->C: message acknowledgement | ||
595 | MSG_PSYC_HISTORY_REPLAY MsgType = 701 // C->S: request channel history replay from PSYCstore. | ||
596 | MSG_PSYC_HISTORY_RESULT MsgType = 702 // S->C: result for a channel history request | ||
597 | MSG_PSYC_STATE_GET MsgType = 703 // C->S: request best matching state variable from PSYCstore. | ||
598 | MSG_PSYC_STATE_GET_PREFIX MsgType = 704 // C->S: request state variables with a given prefix from PSYCstore. | ||
599 | MSG_PSYC_STATE_RESULT MsgType = 705 // S->C: result for a state request. | ||
600 | |||
601 | //------------------------------------------------------------------ | ||
602 | // CONVERSATION message types | ||
603 | //------------------------------------------------------------------ | ||
604 | |||
605 | MSG_CONVERSATION_AUDIO MsgType = 730 // Message to transmit the audio between helper and speaker/microphone library. | ||
606 | MSG_CONVERSATION_CS_PHONE_REGISTER MsgType = 731 // Client -> Server message to register a phone. | ||
607 | MSG_CONVERSATION_CS_PHONE_PICK_UP MsgType = 732 // Client -> Server message to reject/hangup a call | ||
608 | MSG_CONVERSATION_CS_PHONE_HANG_UP MsgType = 733 // Client -> Server message to reject/hangup a call | ||
609 | MSG_CONVERSATION_CS_PHONE_CALL MsgType = 734 // Client <- Server message to indicate a ringing phone | ||
610 | MSG_CONVERSATION_CS_PHONE_RING MsgType = 735 // Client <- Server message to indicate a ringing phone | ||
611 | MSG_CONVERSATION_CS_PHONE_SUSPEND MsgType = 736 // Client <-> Server message to suspend connection. | ||
612 | MSG_CONVERSATION_CS_PHONE_RESUME MsgType = 737 // Client <-> Server message to resume connection. | ||
613 | MSG_CONVERSATION_CS_PHONE_PICKED_UP MsgType = 738 // Service -> Client message to notify that phone was picked up. | ||
614 | MSG_CONVERSATION_CS_AUDIO MsgType = 739 // Client <-> Server message to send audio data. | ||
615 | MSG_CONVERSATION_CADET_PHONE_RING MsgType = 740 // Cadet: call initiation | ||
616 | MSG_CONVERSATION_CADET_PHONE_HANG_UP MsgType = 741 // Cadet: hang up / refuse call | ||
617 | MSG_CONVERSATION_CADET_PHONE_PICK_UP MsgType = 742 // Cadet: pick up phone (establish audio channel) | ||
618 | MSG_CONVERSATION_CADET_PHONE_SUSPEND MsgType = 743 // Cadet: phone suspended. | ||
619 | MSG_CONVERSATION_CADET_PHONE_RESUME MsgType = 744 // Cadet: phone resumed. | ||
620 | MSG_CONVERSATION_CADET_AUDIO MsgType = 745 // Cadet: audio data | ||
621 | |||
622 | //------------------------------------------------------------------ | ||
623 | // MULTICAST message types | ||
624 | //------------------------------------------------------------------ | ||
625 | |||
626 | MSG_MULTICAST_ORIGIN_START MsgType = 750 // C->S: Start the origin. | ||
627 | MSG_MULTICAST_MEMBER_JOIN MsgType = 751 // C->S: Join group as a member. | ||
628 | 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. | ||
629 | 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. | ||
630 | MSG_MULTICAST_PART_REQUEST MsgType = 754 // A peer wants to part the group. | ||
631 | 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. | ||
632 | MSG_MULTICAST_GROUP_END MsgType = 756 // Group terminated. | ||
633 | MSG_MULTICAST_MESSAGE MsgType = 757 // C<->S<->T: Multicast message from the origin to all members. | ||
634 | MSG_MULTICAST_REQUEST MsgType = 758 // C<->S<->T: Unicast request from a group member to the origin. | ||
635 | MSG_MULTICAST_FRAGMENT_ACK MsgType = 759 // C->S: Acknowledgement of a message or request fragment for the client. | ||
636 | MSG_MULTICAST_REPLAY_REQUEST MsgType = 760 // C<->S<->T: Replay request from a group member to another member. | ||
637 | MSG_MULTICAST_REPLAY_RESPONSE MsgType = 761 // C<->S<->T: Replay response from a group member to another member. | ||
638 | MSG_MULTICAST_REPLAY_RESPONSE_END MsgType = 762 // C<->S: End of replay response. | ||
639 | |||
640 | //------------------------------------------------------------------ | ||
641 | // SECRETSHARING message types | ||
642 | //------------------------------------------------------------------ | ||
643 | |||
644 | MSG_SECRETSHARING_CLIENT_GENERATE MsgType = 780 // Establish a new session. | ||
645 | MSG_SECRETSHARING_CLIENT_DECRYPT MsgType = 781 // Request the decryption of a ciphertext. | ||
646 | MSG_SECRETSHARING_CLIENT_DECRYPT_DONE MsgType = 782 // The service succeeded in decrypting a ciphertext. | ||
647 | MSG_SECRETSHARING_CLIENT_SECRET_READY MsgType = 783 // Contains the peer's share. | ||
648 | |||
649 | //------------------------------------------------------------------ | ||
650 | // PEERSTORE message types | ||
651 | //------------------------------------------------------------------ | ||
652 | |||
653 | MSG_PEERSTORE_STORE MsgType = 820 // Store request message | ||
654 | MSG_PEERSTORE_ITERATE MsgType = 821 // Iteration request | ||
655 | MSG_PEERSTORE_ITERATE_RECORD MsgType = 822 // Iteration record message | ||
656 | MSG_PEERSTORE_ITERATE_END MsgType = 823 // Iteration end message | ||
657 | MSG_PEERSTORE_WATCH MsgType = 824 // Watch request | ||
658 | MSG_PEERSTORE_WATCH_RECORD MsgType = 825 // Watch response | ||
659 | MSG_PEERSTORE_WATCH_CANCEL MsgType = 826 // Watch cancel request | ||
660 | |||
661 | //------------------------------------------------------------------ | ||
662 | // SOCIAL message types | ||
663 | //------------------------------------------------------------------ | ||
664 | |||
665 | MSG_SOCIAL_RESULT_CODE MsgType = 840 // S->C: result of an operation | ||
666 | MSG_SOCIAL_HOST_ENTER MsgType = 841 // C->S: request to enter a place as the host | ||
667 | MSG_SOCIAL_HOST_ENTER_ACK MsgType = 842 // S->C: host enter acknowledgement | ||
668 | MSG_SOCIAL_GUEST_ENTER MsgType = 843 // C->S: request to enter a place as a guest | ||
669 | MSG_SOCIAL_GUEST_ENTER_BY_NAME MsgType = 844 // C->S: request to enter a place as a guest, using a GNS address | ||
670 | MSG_SOCIAL_GUEST_ENTER_ACK MsgType = 845 // S->C: guest enter acknowledgement | ||
671 | MSG_SOCIAL_ENTRY_REQUEST MsgType = 846 // P->S->C: incoming entry request from PSYC | ||
672 | MSG_SOCIAL_ENTRY_DECISION MsgType = 847 // C->S->P: decision about an entry request | ||
673 | MSG_SOCIAL_PLACE_LEAVE MsgType = 848 // C->S: request to leave a place | ||
674 | MSG_SOCIAL_PLACE_LEAVE_ACK MsgType = 849 // S->C: place leave acknowledgement | ||
675 | MSG_SOCIAL_ZONE_ADD_PLACE MsgType = 850 // C->S: add place to GNS zone | ||
676 | MSG_SOCIAL_ZONE_ADD_NYM MsgType = 851 // C->S: add nym to GNS zone | ||
677 | MSG_SOCIAL_APP_CONNECT MsgType = 852 // C->S: connect application | ||
678 | MSG_SOCIAL_APP_DETACH MsgType = 853 // C->S: detach a place from application | ||
679 | MSG_SOCIAL_APP_EGO MsgType = 854 // S->C: notify about an existing ego | ||
680 | MSG_SOCIAL_APP_EGO_END MsgType = 855 // S->C: end of ego list | ||
681 | MSG_SOCIAL_APP_PLACE MsgType = 856 // S->C: notify about an existing place | ||
682 | MSG_SOCIAL_APP_PLACE_END MsgType = 857 // S->C: end of place list | ||
683 | MSG_SOCIAL_MSG_PROC_SET MsgType = 858 // C->S: set message processing flags | ||
684 | MSG_SOCIAL_MSG_PROC_CLEAR MsgType = 859 // C->S: clear message processing flags | ||
685 | |||
686 | //------------------------------------------------------------------ | ||
687 | // X-VINE DHT messages | ||
688 | //------------------------------------------------------------------ | ||
689 | |||
690 | MSG_XDHT_P2P_TRAIL_SETUP MsgType = 880 // Trail setup request is received by a peer. | ||
691 | MSG_XDHT_P2P_TRAIL_SETUP_RESULT MsgType = 881 // Trail to a particular peer is returned to this peer. | ||
692 | MSG_XDHT_P2P_VERIFY_SUCCESSOR MsgType = 882 // Verify if your immediate successor is still your immediate successor. | ||
693 | MSG_XDHT_P2P_NOTIFY_NEW_SUCCESSOR MsgType = 883 // Notify your new immediate successor that you are its new predecessor. | ||
694 | MSG_XDHT_P2P_VERIFY_SUCCESSOR_RESULT MsgType = 884 // Message which contains the immediate predecessor of requested successor | ||
695 | MSG_XDHT_P2P_GET_RESULT MsgType = 885 // Message which contains the get result. | ||
696 | MSG_XDHT_P2P_TRAIL_SETUP_REJECTION MsgType = 886 // Trail Rejection Message. | ||
697 | MSG_XDHT_P2P_TRAIL_TEARDOWN MsgType = 887 // Trail Tear down Message. | ||
698 | MSG_XDHT_P2P_ADD_TRAIL MsgType = 888 // Routing table add message. | ||
699 | MSG_XDHT_P2P_PUT MsgType = 890 // Peer is storing the data in DHT. | ||
700 | MSG_XDHT_P2P_GET MsgType = 891 // Peer tries to find data in DHT. | ||
701 | MSG_XDHT_P2P_NOTIFY_SUCCESSOR_CONFIRMATION MsgType = 892 // Send back peer that considers you are its successor. | ||
702 | |||
703 | MSG_DHT_ACT_MALICIOUS MsgType = 893 // Turn X-VINE DHT service malicious | ||
704 | MSG_DHT_CLIENT_ACT_MALICIOUS_OK MsgType = 894 // Acknowledge receiving ACT MALICIOUS request | ||
705 | |||
706 | //------------------------------------------------------------------ | ||
707 | // Whanau DHT messages | ||
708 | //------------------------------------------------------------------ | ||
709 | |||
710 | MSG_WDHT_RANDOM_WALK MsgType = 910 // This message contains the query for performing a random walk | ||
711 | MSG_WDHT_RANDOM_WALK_RESPONSE MsgType = 911 // This message contains the result of a random walk | ||
712 | MSG_WDHT_TRAIL_DESTROY MsgType = 912 // This message contains a notification for the death of a trail | ||
713 | MSG_WDHT_TRAIL_ROUTE MsgType = 913 // This message are used to route a query to a peer | ||
714 | MSG_WDHT_SUCCESSOR_FIND MsgType = 914 // This message contains the query to transfer successor values. | ||
715 | MSG_WDHT_GET MsgType = 915 // Message which contains the get query | ||
716 | MSG_WDHT_PUT MsgType = 916 // Message which contains the "put", a response to #WDHT_SUCCESSOR_FIND. | ||
717 | MSG_WDHT_GET_RESULT MsgType = 917 // Message which contains the get result, a response to #WDHT_GET. | ||
718 | |||
719 | //------------------------------------------------------------------ | ||
720 | // RPS messages | ||
721 | //------------------------------------------------------------------ | ||
722 | |||
723 | MSG_RPS_PP_CHECK_LIVE MsgType = 950 // RPS check liveliness message to check liveliness of other peer | ||
724 | MSG_RPS_PP_PUSH MsgType = 951 // RPS PUSH message to push own ID to another peer | ||
725 | MSG_RPS_PP_PULL_REQUEST MsgType = 952 // RPS PULL REQUEST message to request the local view of another peer | ||
726 | MSG_RPS_PP_PULL_REPLY MsgType = 953 // RPS PULL REPLY message which contains the view of the other peer | ||
727 | MSG_RPS_CS_SEED MsgType = 954 // RPS CS SEED Message for the Client to seed peers into rps | ||
728 | MSG_RPS_ACT_MALICIOUS MsgType = 955 // Turn RPS service malicious | ||
729 | MSG_RPS_CS_SUB_START MsgType = 956 // RPS client-service message to start a sub sampler | ||
730 | MSG_RPS_CS_SUB_STOP MsgType = 957 // RPS client-service message to stop a sub sampler | ||
731 | |||
732 | //------------------------------------------------------------------ | ||
733 | // RECLAIM messages | ||
734 | //------------------------------------------------------------------ | ||
735 | |||
736 | MSG_RECLAIM_ATTRIBUTE_STORE MsgType = 961 | ||
737 | MSG_RECLAIM_SUCCESS_RESPONSE MsgType = 962 | ||
738 | MSG_RECLAIM_ATTRIBUTE_ITERATION_START MsgType = 963 | ||
739 | MSG_RECLAIM_ATTRIBUTE_ITERATION_STOP MsgType = 964 | ||
740 | MSG_RECLAIM_ATTRIBUTE_ITERATION_NEXT MsgType = 965 | ||
741 | MSG_RECLAIM_ATTRIBUTE_RESULT MsgType = 966 | ||
742 | MSG_RECLAIM_ISSUE_TICKET MsgType = 967 | ||
743 | MSG_RECLAIM_TICKET_RESULT MsgType = 968 | ||
744 | MSG_RECLAIM_REVOKE_TICKET MsgType = 969 | ||
745 | MSG_RECLAIM_REVOKE_TICKET_RESULT MsgType = 970 | ||
746 | MSG_RECLAIM_CONSUME_TICKET MsgType = 971 | ||
747 | MSG_RECLAIM_CONSUME_TICKET_RESULT MsgType = 972 | ||
748 | MSG_RECLAIM_TICKET_ITERATION_START MsgType = 973 | ||
749 | MSG_RECLAIM_TICKET_ITERATION_STOP MsgType = 974 | ||
750 | MSG_RECLAIM_TICKET_ITERATION_NEXT MsgType = 975 | ||
751 | MSG_RECLAIM_ATTRIBUTE_DELETE MsgType = 976 | ||
752 | |||
753 | //------------------------------------------------------------------ | ||
754 | // CREDENTIAL messages | ||
755 | //------------------------------------------------------------------ | ||
756 | |||
757 | MSG_CREDENTIAL_VERIFY MsgType = 981 // | ||
758 | MSG_CREDENTIAL_VERIFY_RESULT MsgType = 982 // | ||
759 | MSG_CREDENTIAL_COLLECT MsgType = 983 // | ||
760 | MSG_CREDENTIAL_COLLECT_RESULT MsgType = 984 // | ||
761 | |||
762 | //------------------------------------------------------------------ | ||
763 | // CADET messages | ||
764 | //------------------------------------------------------------------ | ||
765 | |||
766 | MSG_CADET_CONNECTION_CREATE MsgType = 1000 // Request the creation of a connection | ||
767 | MSG_CADET_CONNECTION_CREATE_ACK MsgType = 1001 // Send origin an ACK that the connection is complete | ||
768 | MSG_CADET_CONNECTION_BROKEN MsgType = 1002 // Notify that a connection is no longer valid | ||
769 | MSG_CADET_CONNECTION_DESTROY MsgType = 1003 // Request the destuction of a connection | ||
770 | MSG_CADET_CONNECTION_PATH_CHANGED_UNIMPLEMENTED MsgType = 1004 // At some point, the route will spontaneously change TODO | ||
771 | MSG_CADET_CONNECTION_HOP_BY_HOP_ENCRYPTED_ACK MsgType = 1005 // Hop-by-hop, connection dependent ACK. deprecated | ||
772 | |||
773 | 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 | ||
774 | MSG_CADET_TUNNEL_KX MsgType = 1007 // Axolotl key exchange. | ||
775 | MSG_CADET_TUNNEL_ENCRYPTED MsgType = 1008 // Axolotl encrypted data. | ||
776 | MSG_CADET_TUNNEL_KX_AUTH MsgType = 1009 // Axolotl key exchange response with authentication. | ||
777 | |||
778 | MSG_CADET_CHANNEL_APP_DATA MsgType = 1010 // Payload data (inside an encrypted tunnel). | ||
779 | MSG_CADET_CHANNEL_APP_DATA_ACK MsgType = 1011 // Confirm payload data end-to-end. | ||
780 | MSG_CADET_CHANNEL_KEEPALIVE MsgType = 1012 // Announce connection is still alive (direction sensitive). | ||
781 | MSG_CADET_CHANNEL_OPEN MsgType = 1013 // Ask the cadet service to create a new channel. | ||
782 | MSG_CADET_CHANNEL_DESTROY MsgType = 1014 // Ask the cadet service to destroy a channel. | ||
783 | MSG_CADET_CHANNEL_OPEN_ACK MsgType = 1015 // Confirm the creation of a channel | ||
784 | MSG_CADET_CHANNEL_OPEN_NACK_DEPRECATED MsgType = 1016 // Reject the creation of a channel deprecated | ||
785 | |||
786 | MSG_CADET_LOCAL_DATA MsgType = 1020 // Payload client <-> service | ||
787 | MSG_CADET_LOCAL_ACK MsgType = 1021 // Local ACK for data. | ||
788 | MSG_CADET_LOCAL_PORT_OPEN MsgType = 1022 // Start listening on a port. | ||
789 | MSG_CADET_LOCAL_PORT_CLOSE MsgType = 1023 // Stop listening on a port. | ||
790 | MSG_CADET_LOCAL_CHANNEL_CREATE MsgType = 1024 // Ask the cadet service to create a new channel. | ||
791 | MSG_CADET_LOCAL_CHANNEL_DESTROY MsgType = 1025 // Tell client that a channel was destroyed. | ||
792 | |||
793 | MSG_CADET_LOCAL_REQUEST_INFO_CHANNEL MsgType = 1030 // Local information about all channels of service. | ||
794 | MSG_CADET_LOCAL_INFO_CHANNEL MsgType = 1031 // Local information of service about a specific channel. | ||
795 | MSG_CADET_LOCAL_INFO_CHANNEL_END MsgType = 1032 // End of local information of service about channels. | ||
796 | MSG_CADET_LOCAL_REQUEST_INFO_PEERS MsgType = 1033 // Request local information about all peers known to the service. | ||
797 | MSG_CADET_LOCAL_INFO_PEERS MsgType = 1034 // Local information about all peers known to the service. | ||
798 | MSG_CADET_LOCAL_INFO_PEERS_END MsgType = 1035 // End of local information about all peers known to the service. | ||
799 | MSG_CADET_LOCAL_REQUEST_INFO_PATH MsgType = 1036 // Request local information of service about paths to specific peer. | ||
800 | MSG_CADET_LOCAL_INFO_PATH MsgType = 1037 // Local information of service about a specific path. | ||
801 | MSG_CADET_LOCAL_INFO_PATH_END MsgType = 1038 // End of local information of service about a specific path. | ||
802 | MSG_CADET_LOCAL_REQUEST_INFO_TUNNELS MsgType = 1039 // Request local information about all tunnels of service. | ||
803 | MSG_CADET_LOCAL_INFO_TUNNELS MsgType = 1040 // Local information about all tunnels of service. | ||
804 | MSG_CADET_LOCAL_INFO_TUNNELS_END MsgType = 1041 // End of local information about all tunnels of service. | ||
805 | |||
806 | MSG_CADET_CLI MsgType = 1059 // Traffic (net-cat style) used by the Command Line Interface. | ||
807 | |||
808 | //------------------------------------------------------------------ | ||
809 | // NAT messages | ||
810 | //------------------------------------------------------------------ | ||
811 | |||
812 | MSG_NAT_REGISTER MsgType = 1060 // Message to ask NAT service to register a client. | ||
813 | MSG_NAT_HANDLE_STUN MsgType = 1061 // Message to ask NAT service to handle a STUN packet. | ||
814 | MSG_NAT_REQUEST_CONNECTION_REVERSAL MsgType = 1062 // Message to ask NAT service to request connection reversal. | ||
815 | MSG_NAT_CONNECTION_REVERSAL_REQUESTED MsgType = 1063 // Message to from NAT service notifying us that connection reversal was requested by another peer. | ||
816 | MSG_NAT_ADDRESS_CHANGE MsgType = 1064 // Message to from NAT service notifying us that one of our addresses changed. | ||
817 | MSG_NAT_AUTO_REQUEST_CFG MsgType = 1066 // Message to ask NAT service to request autoconfiguration. | ||
818 | MSG_NAT_AUTO_CFG_RESULT MsgType = 1065 // Message from NAT service with the autoconfiguration result. | ||
819 | |||
820 | //------------------------------------------------------------------ | ||
821 | // AUCTION messages | ||
822 | //------------------------------------------------------------------ | ||
823 | |||
824 | MSG_AUCTION_CLIENT_CREATE MsgType = 1110 // Client wants to create a new auction. | ||
825 | MSG_AUCTION_CLIENT_JOIN MsgType = 1111 // Client wants to join an existing auction. | ||
826 | MSG_AUCTION_CLIENT_OUTCOME MsgType = 1112 // Service reports the auction outcome to the client. | ||
827 | |||
828 | //------------------------------------------------------------------ | ||
829 | // RPS_DEBUG messages | ||
830 | //------------------------------------------------------------------ | ||
831 | |||
832 | MSG_RPS_CS_DEBUG_VIEW_REQUEST MsgType = 1130 // Request updates of the view | ||
833 | MSG_RPS_CS_DEBUG_VIEW_REPLY MsgType = 1131 // Send update of the view | ||
834 | MSG_RPS_CS_DEBUG_VIEW_CANCEL MsgType = 1132 // Cancel getting updates of the view | ||
835 | MSG_RPS_CS_DEBUG_STREAM_REQUEST MsgType = 1133 // Request biased input stream | ||
836 | MSG_RPS_CS_DEBUG_STREAM_REPLY MsgType = 1134 // Send peer of biased stream | ||
837 | MSG_RPS_CS_DEBUG_STREAM_CANCEL MsgType = 1135 // Cancel getting biased stream | ||
838 | |||
839 | //------------------------------------------------------------------ | ||
840 | // CATCH-ALL_DEBUG message | ||
841 | //------------------------------------------------------------------ | ||
842 | |||
843 | MSG_ALL MsgType = 65535 // Type used to match 'all' message types. | ||
844 | ) | ||
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 @@ | |||
1 | // Code generated by "stringer -type=MsgType"; DO NOT EDIT. | ||
2 | |||
3 | package enums | ||
4 | |||
5 | import "strconv" | ||
6 | |||
7 | func _() { | ||
8 | // An "invalid array index" compiler error signifies that the constant values have changed. | ||
9 | // Re-run the stringer command to generate them again. | ||
10 | var x [1]struct{} | ||
11 | _ = x[MSG_TEST-1] | ||
12 | _ = x[MSG_DUMMY-2] | ||
13 | _ = x[MSG_DUMMY2-3] | ||
14 | _ = x[MSG_RESOLVER_REQUEST-4] | ||
15 | _ = x[MSG_RESOLVER_RESPONSE-5] | ||
16 | _ = x[MSG_REQUEST_AGPL-6] | ||
17 | _ = x[MSG_RESPONSE_AGPL-7] | ||
18 | _ = x[MSG_ARM_START-8] | ||
19 | _ = x[MSG_ARM_STOP-9] | ||
20 | _ = x[MSG_ARM_RESULT-10] | ||
21 | _ = x[MSG_ARM_STATUS-11] | ||
22 | _ = x[MSG_ARM_LIST-12] | ||
23 | _ = x[MSG_ARM_LIST_RESULT-13] | ||
24 | _ = x[MSG_ARM_MONITOR-14] | ||
25 | _ = x[MSG_ARM_TEST-15] | ||
26 | _ = x[MSG_HELLO_LEGACY-16] | ||
27 | _ = x[MSG_HELLO-17] | ||
28 | _ = x[MSG_FRAGMENT-18] | ||
29 | _ = x[MSG_FRAGMENT_ACK-19] | ||
30 | _ = x[MSG_WLAN_DATA_TO_HELPER-39] | ||
31 | _ = x[MSG_WLAN_DATA_FROM_HELPER-40] | ||
32 | _ = x[MSG_WLAN_HELPER_CONTROL-41] | ||
33 | _ = x[MSG_WLAN_ADVERTISEMENT-42] | ||
34 | _ = x[MSG_WLAN_DATA-43] | ||
35 | _ = x[MSG_DV_RECV-44] | ||
36 | _ = x[MSG_DV_SEND-45] | ||
37 | _ = x[MSG_DV_SEND_ACK-46] | ||
38 | _ = x[MSG_DV_ROUTE-47] | ||
39 | _ = x[MSG_DV_START-48] | ||
40 | _ = x[MSG_DV_CONNECT-49] | ||
41 | _ = x[MSG_DV_DISCONNECT-50] | ||
42 | _ = x[MSG_DV_SEND_NACK-51] | ||
43 | _ = x[MSG_DV_DISTANCE_CHANGED-52] | ||
44 | _ = x[MSG_DV_BOX-53] | ||
45 | _ = x[MSG_TRANSPORT_XU_MESSAGE-55] | ||
46 | _ = x[MSG_TRANSPORT_UDP_MESSAGE-56] | ||
47 | _ = x[MSG_TRANSPORT_UDP_ACK-57] | ||
48 | _ = x[MSG_TRANSPORT_TCP_NAT_PROBE-60] | ||
49 | _ = x[MSG_TRANSPORT_TCP_WELCOME-61] | ||
50 | _ = x[MSG_TRANSPORT_ATS-62] | ||
51 | _ = x[MSG_NAT_TEST-63] | ||
52 | _ = x[MSG_CORE_INIT-64] | ||
53 | _ = x[MSG_CORE_INIT_REPLY-65] | ||
54 | _ = x[MSG_CORE_NOTIFY_CONNECT-67] | ||
55 | _ = x[MSG_CORE_NOTIFY_DISCONNECT-68] | ||
56 | _ = x[MSG_CORE_NOTIFY_STATUS_CHANGE-69] | ||
57 | _ = x[MSG_CORE_NOTIFY_INBOUND-70] | ||
58 | _ = x[MSG_CORE_NOTIFY_OUTBOUND-71] | ||
59 | _ = x[MSG_CORE_SEND_REQUEST-74] | ||
60 | _ = x[MSG_CORE_SEND_READY-75] | ||
61 | _ = x[MSG_CORE_SEND-76] | ||
62 | _ = x[MSG_CORE_MONITOR_PEERS-78] | ||
63 | _ = x[MSG_CORE_MONITOR_NOTIFY-79] | ||
64 | _ = x[MSG_CORE_ENCRYPTED_MESSAGE-82] | ||
65 | _ = x[MSG_CORE_PING-83] | ||
66 | _ = x[MSG_CORE_PONG-84] | ||
67 | _ = x[MSG_CORE_HANGUP-85] | ||
68 | _ = x[MSG_CORE_COMPRESSED_TYPE_MAP-86] | ||
69 | _ = x[MSG_CORE_BINARY_TYPE_MAP-87] | ||
70 | _ = x[MSG_CORE_EPHEMERAL_KEY-88] | ||
71 | _ = x[MSG_CORE_CONFIRM_TYPE_MAP-89] | ||
72 | _ = x[MSG_DATASTORE_RESERVE-92] | ||
73 | _ = x[MSG_DATASTORE_RELEASE_RESERVE-93] | ||
74 | _ = x[MSG_DATASTORE_STATUS-94] | ||
75 | _ = x[MSG_DATASTORE_PUT-95] | ||
76 | _ = x[MSG_DATASTORE_GET-97] | ||
77 | _ = x[MSG_DATASTORE_GET_REPLICATION-98] | ||
78 | _ = x[MSG_DATASTORE_GET_ZERO_ANONYMITY-99] | ||
79 | _ = x[MSG_DATASTORE_DATA-100] | ||
80 | _ = x[MSG_DATASTORE_DATA_END-101] | ||
81 | _ = x[MSG_DATASTORE_REMOVE-102] | ||
82 | _ = x[MSG_DATASTORE_DROP-103] | ||
83 | _ = x[MSG_DATASTORE_GET_KEY-104] | ||
84 | _ = x[MSG_FS_REQUEST_LOC_SIGN-126] | ||
85 | _ = x[MSG_FS_REQUEST_LOC_SIGNATURE-127] | ||
86 | _ = x[MSG_FS_INDEX_START-128] | ||
87 | _ = x[MSG_FS_INDEX_START_OK-129] | ||
88 | _ = x[MSG_FS_INDEX_START_FAILED-130] | ||
89 | _ = x[MSG_FS_INDEX_LIST_GET-131] | ||
90 | _ = x[MSG_FS_INDEX_LIST_ENTRY-132] | ||
91 | _ = x[MSG_FS_INDEX_LIST_END-133] | ||
92 | _ = x[MSG_FS_UNINDEX-134] | ||
93 | _ = x[MSG_FS_UNINDEX_OK-135] | ||
94 | _ = x[MSG_FS_START_SEARCH-136] | ||
95 | _ = x[MSG_FS_GET-137] | ||
96 | _ = x[MSG_FS_PUT-138] | ||
97 | _ = x[MSG_FS_MIGRATION_STOP-139] | ||
98 | _ = x[MSG_FS_CADET_QUERY-140] | ||
99 | _ = x[MSG_FS_CADET_REPLY-141] | ||
100 | _ = x[MSG_DHT_CLIENT_PUT-142] | ||
101 | _ = x[MSG_DHT_CLIENT_GET-143] | ||
102 | _ = x[MSG_DHT_CLIENT_GET_STOP-144] | ||
103 | _ = x[MSG_DHT_CLIENT_RESULT-145] | ||
104 | _ = x[MSG_DHT_P2P_PUT-146] | ||
105 | _ = x[MSG_DHT_P2P_GET-147] | ||
106 | _ = x[MSG_DHT_P2P_RESULT-148] | ||
107 | _ = x[MSG_DHT_MONITOR_GET-149] | ||
108 | _ = x[MSG_DHT_MONITOR_GET_RESP-150] | ||
109 | _ = x[MSG_DHT_MONITOR_PUT-151] | ||
110 | _ = x[MSG_DHT_MONITOR_PUT_RESP-152] | ||
111 | _ = x[MSG_DHT_MONITOR_START-153] | ||
112 | _ = x[MSG_DHT_MONITOR_STOP-154] | ||
113 | _ = x[MSG_DHT_CLIENT_GET_RESULTS_KNOWN-156] | ||
114 | _ = x[MSG_DHT_P2P_HELLO-157] | ||
115 | _ = x[MSG_DHT_CORE-158] | ||
116 | _ = x[MSG_DHT_CLIENT_HELLO_URL-159] | ||
117 | _ = x[MSG_DHT_CLIENT_HELLO_GET-161] | ||
118 | _ = x[MSG_HOSTLIST_ADVERTISEMENT-160] | ||
119 | _ = x[MSG_STATISTICS_SET-168] | ||
120 | _ = x[MSG_STATISTICS_GET-169] | ||
121 | _ = x[MSG_STATISTICS_VALUE-170] | ||
122 | _ = x[MSG_STATISTICS_END-171] | ||
123 | _ = x[MSG_STATISTICS_WATCH-172] | ||
124 | _ = x[MSG_STATISTICS_WATCH_VALUE-173] | ||
125 | _ = x[MSG_STATISTICS_DISCONNECT-174] | ||
126 | _ = x[MSG_STATISTICS_DISCONNECT_CONFIRM-175] | ||
127 | _ = x[MSG_VPN_HELPER-185] | ||
128 | _ = x[MSG_VPN_ICMP_TO_SERVICE-190] | ||
129 | _ = x[MSG_VPN_ICMP_TO_INTERNET-191] | ||
130 | _ = x[MSG_VPN_ICMP_TO_VPN-192] | ||
131 | _ = x[MSG_VPN_DNS_TO_INTERNET-193] | ||
132 | _ = x[MSG_VPN_DNS_FROM_INTERNET-194] | ||
133 | _ = x[MSG_VPN_TCP_TO_SERVICE_START-195] | ||
134 | _ = x[MSG_VPN_TCP_TO_INTERNET_START-196] | ||
135 | _ = x[MSG_VPN_TCP_DATA_TO_EXIT-197] | ||
136 | _ = x[MSG_VPN_TCP_DATA_TO_VPN-198] | ||
137 | _ = x[MSG_VPN_UDP_TO_SERVICE-199] | ||
138 | _ = x[MSG_VPN_UDP_TO_INTERNET-200] | ||
139 | _ = x[MSG_VPN_UDP_REPLY-201] | ||
140 | _ = x[MSG_VPN_CLIENT_REDIRECT_TO_IP-202] | ||
141 | _ = x[MSG_VPN_CLIENT_REDIRECT_TO_SERVICE-203] | ||
142 | _ = x[MSG_VPN_CLIENT_USE_IP-204] | ||
143 | _ = x[MSG_DNS_CLIENT_INIT-211] | ||
144 | _ = x[MSG_DNS_CLIENT_REQUEST-212] | ||
145 | _ = x[MSG_DNS_CLIENT_RESPONSE-213] | ||
146 | _ = x[MSG_DNS_HELPER-214] | ||
147 | _ = x[MSG_CHAT_JOIN_REQUEST-300] | ||
148 | _ = x[MSG_CHAT_JOIN_NOTIFICATION-301] | ||
149 | _ = x[MSG_CHAT_LEAVE_NOTIFICATION-302] | ||
150 | _ = x[MSG_CHAT_MESSAGE_NOTIFICATION-303] | ||
151 | _ = x[MSG_CHAT_TRANSMIT_REQUEST-304] | ||
152 | _ = x[MSG_CHAT_CONFIRMATION_RECEIPT-305] | ||
153 | _ = x[MSG_CHAT_CONFIRMATION_NOTIFICATION-306] | ||
154 | _ = x[MSG_CHAT_P2P_JOIN_NOTIFICATION-307] | ||
155 | _ = x[MSG_CHAT_P2P_LEAVE_NOTIFICATION-308] | ||
156 | _ = x[MSG_CHAT_P2P_SYNC_REQUEST-309] | ||
157 | _ = x[MSG_CHAT_P2P_MESSAGE_NOTIFICATION-310] | ||
158 | _ = x[MSG_CHAT_P2P_CONFIRMATION_RECEIPT-311] | ||
159 | _ = x[MSG_NSE_START-321] | ||
160 | _ = x[MSG_NSE_P2P_FLOOD-322] | ||
161 | _ = x[MSG_NSE_ESTIMATE-323] | ||
162 | _ = x[MSG_PEERINFO_GET-330] | ||
163 | _ = x[MSG_PEERINFO_GET_ALL-331] | ||
164 | _ = x[MSG_PEERINFO_INFO-332] | ||
165 | _ = x[MSG_PEERINFO_INFO_END-333] | ||
166 | _ = x[MSG_PEERINFO_NOTIFY-334] | ||
167 | _ = x[MSG_ATS_START-340] | ||
168 | _ = x[MSG_ATS_REQUEST_ADDRESS-341] | ||
169 | _ = x[MSG_ATS_REQUEST_ADDRESS_CANCEL-342] | ||
170 | _ = x[MSG_ATS_ADDRESS_UPDATE-343] | ||
171 | _ = x[MSG_ATS_ADDRESS_DESTROYED-344] | ||
172 | _ = x[MSG_ATS_ADDRESS_SUGGESTION-345] | ||
173 | _ = x[MSG_ATS_PEER_INFORMATION-346] | ||
174 | _ = x[MSG_ATS_RESERVATION_REQUEST-347] | ||
175 | _ = x[MSG_ATS_RESERVATION_RESULT-348] | ||
176 | _ = x[MSG_ATS_PREFERENCE_CHANGE-349] | ||
177 | _ = x[MSG_ATS_SESSION_RELEASE-350] | ||
178 | _ = x[MSG_ATS_ADDRESS_ADD-353] | ||
179 | _ = x[MSG_ATS_ADDRESSLIST_REQUEST-354] | ||
180 | _ = x[MSG_ATS_ADDRESSLIST_RESPONSE-355] | ||
181 | _ = x[MSG_ATS_PREFERENCE_FEEDBACK-356] | ||
182 | _ = x[MSG_TRANSPORT_START-360] | ||
183 | _ = x[MSG_TRANSPORT_CONNECT-361] | ||
184 | _ = x[MSG_TRANSPORT_DISCONNECT-362] | ||
185 | _ = x[MSG_TRANSPORT_SEND-363] | ||
186 | _ = x[MSG_TRANSPORT_SEND_OK-364] | ||
187 | _ = x[MSG_TRANSPORT_RECV-365] | ||
188 | _ = x[MSG_TRANSPORT_SET_QUOTA-366] | ||
189 | _ = x[MSG_TRANSPORT_ADDRESS_TO_STRING-367] | ||
190 | _ = x[MSG_TRANSPORT_ADDRESS_TO_STRING_REPLY-368] | ||
191 | _ = x[MSG_TRANSPORT_BLACKLIST_INIT-369] | ||
192 | _ = x[MSG_TRANSPORT_BLACKLIST_QUERY-370] | ||
193 | _ = x[MSG_TRANSPORT_BLACKLIST_REPLY-371] | ||
194 | _ = x[MSG_TRANSPORT_PING-372] | ||
195 | _ = x[MSG_TRANSPORT_PONG-373] | ||
196 | _ = x[MSG_TRANSPORT_SESSION_SYN-375] | ||
197 | _ = x[MSG_TRANSPORT_SESSION_SYN_ACK-376] | ||
198 | _ = x[MSG_TRANSPORT_SESSION_ACK-377] | ||
199 | _ = x[MSG_TRANSPORT_SESSION_DISCONNECT-378] | ||
200 | _ = x[MSG_TRANSPORT_SESSION_QUOTA-379] | ||
201 | _ = x[MSG_TRANSPORT_MONITOR_PEER_REQUEST-380] | ||
202 | _ = x[MSG_TRANSPORT_SESSION_KEEPALIVE-381] | ||
203 | _ = x[MSG_TRANSPORT_SESSION_KEEPALIVE_RESPONSE-382] | ||
204 | _ = x[MSG_TRANSPORT_MONITOR_PEER_RESPONSE-383] | ||
205 | _ = x[MSG_TRANSPORT_BROADCAST_BEACON-384] | ||
206 | _ = x[MSG_TRANSPORT_TRAFFIC_METRIC-385] | ||
207 | _ = x[MSG_TRANSPORT_MONITOR_PLUGIN_START-388] | ||
208 | _ = x[MSG_TRANSPORT_MONITOR_PLUGIN_EVENT-389] | ||
209 | _ = x[MSG_TRANSPORT_MONITOR_PLUGIN_SYNC-390] | ||
210 | _ = x[MSG_TRANSPORT_MONITOR_PEER_RESPONSE_END-391] | ||
211 | _ = x[MSG_FS_PUBLISH_HELPER_PROGRESS_FILE-420] | ||
212 | _ = x[MSG_FS_PUBLISH_HELPER_PROGRESS_DIRECTORY-421] | ||
213 | _ = x[MSG_FS_PUBLISH_HELPER_ERROR-422] | ||
214 | _ = x[MSG_FS_PUBLISH_HELPER_SKIP_FILE-423] | ||
215 | _ = x[MSG_FS_PUBLISH_HELPER_COUNTING_DONE-424] | ||
216 | _ = x[MSG_FS_PUBLISH_HELPER_META_DATA-425] | ||
217 | _ = x[MSG_FS_PUBLISH_HELPER_FINISHED-426] | ||
218 | _ = x[MSG_NAMECACHE_LOOKUP_BLOCK-431] | ||
219 | _ = x[MSG_NAMECACHE_LOOKUP_BLOCK_RESPONSE-432] | ||
220 | _ = x[MSG_NAMECACHE_BLOCK_CACHE-433] | ||
221 | _ = x[MSG_NAMECACHE_BLOCK_CACHE_RESPONSE-434] | ||
222 | _ = x[MSG_NAMESTORE_RECORD_STORE-435] | ||
223 | _ = x[MSG_NAMESTORE_RECORD_STORE_RESPONSE-436] | ||
224 | _ = x[MSG_NAMESTORE_RECORD_LOOKUP-437] | ||
225 | _ = x[MSG_NAMESTORE_RECORD_LOOKUP_RESPONSE-438] | ||
226 | _ = x[MSG_NAMESTORE_ZONE_TO_NAME-439] | ||
227 | _ = x[MSG_NAMESTORE_ZONE_TO_NAME_RESPONSE-440] | ||
228 | _ = x[MSG_NAMESTORE_MONITOR_START-441] | ||
229 | _ = x[MSG_NAMESTORE_MONITOR_SYNC-442] | ||
230 | _ = x[MSG_NAMESTORE_RECORD_RESULT-443] | ||
231 | _ = x[MSG_NAMESTORE_MONITOR_NEXT-444] | ||
232 | _ = x[MSG_NAMESTORE_ZONE_ITERATION_START-445] | ||
233 | _ = x[MSG_NAMESTORE_ZONE_ITERATION_NEXT-447] | ||
234 | _ = x[MSG_NAMESTORE_ZONE_ITERATION_STOP-448] | ||
235 | _ = x[MSG_TESTBED_INIT-460] | ||
236 | _ = x[MSG_TESTBED_ADD_HOST-461] | ||
237 | _ = x[MSG_TESTBED_ADD_HOST_SUCCESS-462] | ||
238 | _ = x[MSG_TESTBED_LINK_CONTROLLERS-463] | ||
239 | _ = x[MSG_TESTBED_CREATE_PEER-464] | ||
240 | _ = x[MSG_TESTBED_RECONFIGURE_PEER-465] | ||
241 | _ = x[MSG_TESTBED_START_PEER-466] | ||
242 | _ = x[MSG_TESTBED_STOP_PEER-467] | ||
243 | _ = x[MSG_TESTBED_DESTROY_PEER-468] | ||
244 | _ = x[MSG_TESTBED_CONFIGURE_UNDERLAY_LINK-469] | ||
245 | _ = x[MSG_TESTBED_OVERLAY_CONNECT-470] | ||
246 | _ = x[MSG_TESTBED_PEER_EVENT-471] | ||
247 | _ = x[MSG_TESTBED_PEER_CONNECT_EVENT-472] | ||
248 | _ = x[MSG_TESTBED_OPERATION_FAIL_EVENT-473] | ||
249 | _ = x[MSG_TESTBED_CREATE_PEER_SUCCESS-474] | ||
250 | _ = x[MSG_TESTBED_GENERIC_OPERATION_SUCCESS-475] | ||
251 | _ = x[MSG_TESTBED_GET_PEER_INFORMATION-476] | ||
252 | _ = x[MSG_TESTBED_PEER_INFORMATION-477] | ||
253 | _ = x[MSG_TESTBED_REMOTE_OVERLAY_CONNECT-478] | ||
254 | _ = x[MSG_TESTBED_GET_SLAVE_CONFIGURATION-479] | ||
255 | _ = x[MSG_TESTBED_SLAVE_CONFIGURATION-480] | ||
256 | _ = x[MSG_TESTBED_LINK_CONTROLLERS_RESULT-481] | ||
257 | _ = x[MSG_TESTBED_SHUTDOWN_PEERS-482] | ||
258 | _ = x[MSG_TESTBED_MANAGE_PEER_SERVICE-483] | ||
259 | _ = x[MSG_TESTBED_BARRIER_INIT-484] | ||
260 | _ = x[MSG_TESTBED_BARRIER_CANCEL-485] | ||
261 | _ = x[MSG_TESTBED_BARRIER_STATUS-486] | ||
262 | _ = x[MSG_TESTBED_BARRIER_WAIT-487] | ||
263 | _ = x[MSG_TESTBED_MAX-488] | ||
264 | _ = x[MSG_TESTBED_HELPER_INIT-495] | ||
265 | _ = x[MSG_TESTBED_HELPER_REPLY-496] | ||
266 | _ = x[MSG_GNS_LOOKUP-500] | ||
267 | _ = x[MSG_GNS_LOOKUP_RESULT-501] | ||
268 | _ = x[MSG_GNS_REVERSE_LOOKUP-502] | ||
269 | _ = x[MSG_GNS_REVERSE_LOOKUP_RESULT-503] | ||
270 | _ = x[MSG_CONSENSUS_CLIENT_JOIN-520] | ||
271 | _ = x[MSG_CONSENSUS_CLIENT_INSERT-521] | ||
272 | _ = x[MSG_CONSENSUS_CLIENT_BEGIN-522] | ||
273 | _ = x[MSG_CONSENSUS_CLIENT_RECEIVED_ELEMENT-523] | ||
274 | _ = x[MSG_CONSENSUS_CLIENT_CONCLUDE-524] | ||
275 | _ = x[MSG_CONSENSUS_CLIENT_CONCLUDE_DONE-525] | ||
276 | _ = x[MSG_CONSENSUS_CLIENT_ACK-540] | ||
277 | _ = x[MSG_CONSENSUS_P2P_DELTA_ESTIMATE-541] | ||
278 | _ = x[MSG_CONSENSUS_P2P_DIFFERENCE_DIGEST-542] | ||
279 | _ = x[MSG_CONSENSUS_P2P_ELEMENTS-543] | ||
280 | _ = x[MSG_CONSENSUS_P2P_ELEMENTS_REQUEST-544] | ||
281 | _ = x[MSG_CONSENSUS_P2P_ELEMENTS_REPORT-545] | ||
282 | _ = x[MSG_CONSENSUS_P2P_HELLO-546] | ||
283 | _ = x[MSG_CONSENSUS_P2P_SYNCED-547] | ||
284 | _ = x[MSG_CONSENSUS_P2P_FIN-548] | ||
285 | _ = x[MSG_CONSENSUS_P2P_ABORT-548] | ||
286 | _ = x[MSG_CONSENSUS_P2P_ROUND_CONTEXT-547] | ||
287 | _ = x[MSG_SET_UNION_P2P_REQUEST_FULL-565] | ||
288 | _ = x[MSG_SET_UNION_P2P_DEMAND-566] | ||
289 | _ = x[MSG_SET_UNION_P2P_INQUIRY-567] | ||
290 | _ = x[MSG_SET_UNION_P2P_OFFER-568] | ||
291 | _ = x[MSG_SET_REJECT-569] | ||
292 | _ = x[MSG_SET_CANCEL-570] | ||
293 | _ = x[MSG_SET_ITER_ACK-571] | ||
294 | _ = x[MSG_SET_RESULT-572] | ||
295 | _ = x[MSG_SET_ADD-573] | ||
296 | _ = x[MSG_SET_REMOVE-574] | ||
297 | _ = x[MSG_SET_LISTEN-575] | ||
298 | _ = x[MSG_SET_ACCEPT-576] | ||
299 | _ = x[MSG_SET_EVALUATE-577] | ||
300 | _ = x[MSG_SET_CONCLUDE-578] | ||
301 | _ = x[MSG_SET_REQUEST-579] | ||
302 | _ = x[MSG_SET_CREATE-580] | ||
303 | _ = x[MSG_SET_P2P_OPERATION_REQUEST-581] | ||
304 | _ = x[MSG_SET_UNION_P2P_SE-582] | ||
305 | _ = x[MSG_SET_UNION_P2P_IBF-583] | ||
306 | _ = x[MSG_SET_P2P_ELEMENTS-584] | ||
307 | _ = x[MSG_SET_P2P_ELEMENT_REQUESTS-585] | ||
308 | _ = x[MSG_SET_UNION_P2P_DONE-586] | ||
309 | _ = x[MSG_SET_ITER_REQUEST-587] | ||
310 | _ = x[MSG_SET_ITER_ELEMENT-588] | ||
311 | _ = x[MSG_SET_ITER_DONE-589] | ||
312 | _ = x[MSG_SET_UNION_P2P_SEC-590] | ||
313 | _ = x[MSG_SET_INTERSECTION_P2P_ELEMENT_INFO-591] | ||
314 | _ = x[MSG_SET_INTERSECTION_P2P_BF-592] | ||
315 | _ = x[MSG_SET_INTERSECTION_P2P_DONE-593] | ||
316 | _ = x[MSG_SET_COPY_LAZY_PREPARE-594] | ||
317 | _ = x[MSG_SET_COPY_LAZY_RESPONSE-595] | ||
318 | _ = x[MSG_SET_COPY_LAZY_CONNECT-596] | ||
319 | _ = x[MSG_SET_UNION_P2P_FULL_DONE-597] | ||
320 | _ = x[MSG_SET_UNION_P2P_FULL_ELEMENT-598] | ||
321 | _ = x[MSG_SET_UNION_P2P_OVER-599] | ||
322 | _ = x[MSG_TESTBED_LOGGER_MSG-600] | ||
323 | _ = x[MSG_TESTBED_LOGGER_ACK-601] | ||
324 | _ = x[MSG_REGEX_ANNOUNCE-620] | ||
325 | _ = x[MSG_REGEX_SEARCH-621] | ||
326 | _ = x[MSG_REGEX_RESULT-622] | ||
327 | _ = x[MSG_IDENTITY_START-624] | ||
328 | _ = x[MSG_IDENTITY_RESULT_CODE-625] | ||
329 | _ = x[MSG_IDENTITY_UPDATE-626] | ||
330 | _ = x[MSG_IDENTITY_GET_DEFAULT-627] | ||
331 | _ = x[MSG_IDENTITY_SET_DEFAULT-628] | ||
332 | _ = x[MSG_IDENTITY_CREATE-629] | ||
333 | _ = x[MSG_IDENTITY_RENAME-630] | ||
334 | _ = x[MSG_IDENTITY_DELETE-631] | ||
335 | _ = x[MSG_IDENTITY_LOOKUP-632] | ||
336 | _ = x[MSG_IDENTITY_LOOKUP_BY_NAME-633] | ||
337 | _ = x[MSG_REVOCATION_QUERY-636] | ||
338 | _ = x[MSG_REVOCATION_QUERY_RESPONSE-637] | ||
339 | _ = x[MSG_REVOCATION_REVOKE-638] | ||
340 | _ = x[MSG_REVOCATION_REVOKE_RESPONSE-639] | ||
341 | _ = x[MSG_SCALARPRODUCT_CLIENT_TO_ALICE-640] | ||
342 | _ = x[MSG_SCALARPRODUCT_CLIENT_TO_BOB-641] | ||
343 | _ = x[MSG_SCALARPRODUCT_CLIENT_MULTIPART_ALICE-642] | ||
344 | _ = x[MSG_SCALARPRODUCT_CLIENT_MULTIPART_BOB-643] | ||
345 | _ = x[MSG_SCALARPRODUCT_SESSION_INITIALIZATION-644] | ||
346 | _ = x[MSG_SCALARPRODUCT_ALICE_CRYPTODATA-645] | ||
347 | _ = x[MSG_SCALARPRODUCT_BOB_CRYPTODATA-647] | ||
348 | _ = x[MSG_SCALARPRODUCT_BOB_CRYPTODATA_MULTIPART-648] | ||
349 | _ = x[MSG_SCALARPRODUCT_RESULT-649] | ||
350 | _ = x[MSG_SCALARPRODUCT_ECC_SESSION_INITIALIZATION-650] | ||
351 | _ = x[MSG_SCALARPRODUCT_ECC_ALICE_CRYPTODATA-651] | ||
352 | _ = x[MSG_SCALARPRODUCT_ECC_BOB_CRYPTODATA-652] | ||
353 | _ = x[MSG_PSYCSTORE_MEMBERSHIP_STORE-660] | ||
354 | _ = x[MSG_PSYCSTORE_MEMBERSHIP_TEST-661] | ||
355 | _ = x[MSG_PSYCSTORE_FRAGMENT_STORE-662] | ||
356 | _ = x[MSG_PSYCSTORE_FRAGMENT_GET-663] | ||
357 | _ = x[MSG_PSYCSTORE_MESSAGE_GET-664] | ||
358 | _ = x[MSG_PSYCSTORE_MESSAGE_GET_FRAGMENT-665] | ||
359 | _ = x[MSG_PSYCSTORE_COUNTERS_GET-666] | ||
360 | _ = x[MSG_PSYCSTORE_STATE_MODIFY-668] | ||
361 | _ = x[MSG_PSYCSTORE_STATE_SYNC-669] | ||
362 | _ = x[MSG_PSYCSTORE_STATE_RESET-670] | ||
363 | _ = x[MSG_PSYCSTORE_STATE_HASH_UPDATE-671] | ||
364 | _ = x[MSG_PSYCSTORE_STATE_GET-672] | ||
365 | _ = x[MSG_PSYCSTORE_STATE_GET_PREFIX-673] | ||
366 | _ = x[MSG_PSYCSTORE_RESULT_CODE-674] | ||
367 | _ = x[MSG_PSYCSTORE_RESULT_FRAGMENT-675] | ||
368 | _ = x[MSG_PSYCSTORE_RESULT_COUNTERS-676] | ||
369 | _ = x[MSG_PSYCSTORE_RESULT_STATE-677] | ||
370 | _ = x[MSG_PSYC_RESULT_CODE-680] | ||
371 | _ = x[MSG_PSYC_MASTER_START-681] | ||
372 | _ = x[MSG_PSYC_MASTER_START_ACK-682] | ||
373 | _ = x[MSG_PSYC_SLAVE_JOIN-683] | ||
374 | _ = x[MSG_PSYC_SLAVE_JOIN_ACK-684] | ||
375 | _ = x[MSG_PSYC_PART_REQUEST-685] | ||
376 | _ = x[MSG_PSYC_PART_ACK-686] | ||
377 | _ = x[MSG_PSYC_JOIN_REQUEST-687] | ||
378 | _ = x[MSG_PSYC_JOIN_DECISION-688] | ||
379 | _ = x[MSG_PSYC_CHANNEL_MEMBERSHIP_STORE-689] | ||
380 | _ = x[MSG_PSYC_MESSAGE-691] | ||
381 | _ = x[MSG_PSYC_MESSAGE_HEADER-692] | ||
382 | _ = x[MSG_PSYC_MESSAGE_METHOD-693] | ||
383 | _ = x[MSG_PSYC_MESSAGE_MODIFIER-694] | ||
384 | _ = x[MSG_PSYC_MESSAGE_MOD_CONT-695] | ||
385 | _ = x[MSG_PSYC_MESSAGE_DATA-696] | ||
386 | _ = x[MSG_PSYC_MESSAGE_END-697] | ||
387 | _ = x[MSG_PSYC_MESSAGE_CANCEL-698] | ||
388 | _ = x[MSG_PSYC_MESSAGE_ACK-699] | ||
389 | _ = x[MSG_PSYC_HISTORY_REPLAY-701] | ||
390 | _ = x[MSG_PSYC_HISTORY_RESULT-702] | ||
391 | _ = x[MSG_PSYC_STATE_GET-703] | ||
392 | _ = x[MSG_PSYC_STATE_GET_PREFIX-704] | ||
393 | _ = x[MSG_PSYC_STATE_RESULT-705] | ||
394 | _ = x[MSG_CONVERSATION_AUDIO-730] | ||
395 | _ = x[MSG_CONVERSATION_CS_PHONE_REGISTER-731] | ||
396 | _ = x[MSG_CONVERSATION_CS_PHONE_PICK_UP-732] | ||
397 | _ = x[MSG_CONVERSATION_CS_PHONE_HANG_UP-733] | ||
398 | _ = x[MSG_CONVERSATION_CS_PHONE_CALL-734] | ||
399 | _ = x[MSG_CONVERSATION_CS_PHONE_RING-735] | ||
400 | _ = x[MSG_CONVERSATION_CS_PHONE_SUSPEND-736] | ||
401 | _ = x[MSG_CONVERSATION_CS_PHONE_RESUME-737] | ||
402 | _ = x[MSG_CONVERSATION_CS_PHONE_PICKED_UP-738] | ||
403 | _ = x[MSG_CONVERSATION_CS_AUDIO-739] | ||
404 | _ = x[MSG_CONVERSATION_CADET_PHONE_RING-740] | ||
405 | _ = x[MSG_CONVERSATION_CADET_PHONE_HANG_UP-741] | ||
406 | _ = x[MSG_CONVERSATION_CADET_PHONE_PICK_UP-742] | ||
407 | _ = x[MSG_CONVERSATION_CADET_PHONE_SUSPEND-743] | ||
408 | _ = x[MSG_CONVERSATION_CADET_PHONE_RESUME-744] | ||
409 | _ = x[MSG_CONVERSATION_CADET_AUDIO-745] | ||
410 | _ = x[MSG_MULTICAST_ORIGIN_START-750] | ||
411 | _ = x[MSG_MULTICAST_MEMBER_JOIN-751] | ||
412 | _ = x[MSG_MULTICAST_JOIN_REQUEST-752] | ||
413 | _ = x[MSG_MULTICAST_JOIN_DECISION-753] | ||
414 | _ = x[MSG_MULTICAST_PART_REQUEST-754] | ||
415 | _ = x[MSG_MULTICAST_PART_ACK-755] | ||
416 | _ = x[MSG_MULTICAST_GROUP_END-756] | ||
417 | _ = x[MSG_MULTICAST_MESSAGE-757] | ||
418 | _ = x[MSG_MULTICAST_REQUEST-758] | ||
419 | _ = x[MSG_MULTICAST_FRAGMENT_ACK-759] | ||
420 | _ = x[MSG_MULTICAST_REPLAY_REQUEST-760] | ||
421 | _ = x[MSG_MULTICAST_REPLAY_RESPONSE-761] | ||
422 | _ = x[MSG_MULTICAST_REPLAY_RESPONSE_END-762] | ||
423 | _ = x[MSG_SECRETSHARING_CLIENT_GENERATE-780] | ||
424 | _ = x[MSG_SECRETSHARING_CLIENT_DECRYPT-781] | ||
425 | _ = x[MSG_SECRETSHARING_CLIENT_DECRYPT_DONE-782] | ||
426 | _ = x[MSG_SECRETSHARING_CLIENT_SECRET_READY-783] | ||
427 | _ = x[MSG_PEERSTORE_STORE-820] | ||
428 | _ = x[MSG_PEERSTORE_ITERATE-821] | ||
429 | _ = x[MSG_PEERSTORE_ITERATE_RECORD-822] | ||
430 | _ = x[MSG_PEERSTORE_ITERATE_END-823] | ||
431 | _ = x[MSG_PEERSTORE_WATCH-824] | ||
432 | _ = x[MSG_PEERSTORE_WATCH_RECORD-825] | ||
433 | _ = x[MSG_PEERSTORE_WATCH_CANCEL-826] | ||
434 | _ = x[MSG_SOCIAL_RESULT_CODE-840] | ||
435 | _ = x[MSG_SOCIAL_HOST_ENTER-841] | ||
436 | _ = x[MSG_SOCIAL_HOST_ENTER_ACK-842] | ||
437 | _ = x[MSG_SOCIAL_GUEST_ENTER-843] | ||
438 | _ = x[MSG_SOCIAL_GUEST_ENTER_BY_NAME-844] | ||
439 | _ = x[MSG_SOCIAL_GUEST_ENTER_ACK-845] | ||
440 | _ = x[MSG_SOCIAL_ENTRY_REQUEST-846] | ||
441 | _ = x[MSG_SOCIAL_ENTRY_DECISION-847] | ||
442 | _ = x[MSG_SOCIAL_PLACE_LEAVE-848] | ||
443 | _ = x[MSG_SOCIAL_PLACE_LEAVE_ACK-849] | ||
444 | _ = x[MSG_SOCIAL_ZONE_ADD_PLACE-850] | ||
445 | _ = x[MSG_SOCIAL_ZONE_ADD_NYM-851] | ||
446 | _ = x[MSG_SOCIAL_APP_CONNECT-852] | ||
447 | _ = x[MSG_SOCIAL_APP_DETACH-853] | ||
448 | _ = x[MSG_SOCIAL_APP_EGO-854] | ||
449 | _ = x[MSG_SOCIAL_APP_EGO_END-855] | ||
450 | _ = x[MSG_SOCIAL_APP_PLACE-856] | ||
451 | _ = x[MSG_SOCIAL_APP_PLACE_END-857] | ||
452 | _ = x[MSG_SOCIAL_MSG_PROC_SET-858] | ||
453 | _ = x[MSG_SOCIAL_MSG_PROC_CLEAR-859] | ||
454 | _ = x[MSG_XDHT_P2P_TRAIL_SETUP-880] | ||
455 | _ = x[MSG_XDHT_P2P_TRAIL_SETUP_RESULT-881] | ||
456 | _ = x[MSG_XDHT_P2P_VERIFY_SUCCESSOR-882] | ||
457 | _ = x[MSG_XDHT_P2P_NOTIFY_NEW_SUCCESSOR-883] | ||
458 | _ = x[MSG_XDHT_P2P_VERIFY_SUCCESSOR_RESULT-884] | ||
459 | _ = x[MSG_XDHT_P2P_GET_RESULT-885] | ||
460 | _ = x[MSG_XDHT_P2P_TRAIL_SETUP_REJECTION-886] | ||
461 | _ = x[MSG_XDHT_P2P_TRAIL_TEARDOWN-887] | ||
462 | _ = x[MSG_XDHT_P2P_ADD_TRAIL-888] | ||
463 | _ = x[MSG_XDHT_P2P_PUT-890] | ||
464 | _ = x[MSG_XDHT_P2P_GET-891] | ||
465 | _ = x[MSG_XDHT_P2P_NOTIFY_SUCCESSOR_CONFIRMATION-892] | ||
466 | _ = x[MSG_DHT_ACT_MALICIOUS-893] | ||
467 | _ = x[MSG_DHT_CLIENT_ACT_MALICIOUS_OK-894] | ||
468 | _ = x[MSG_WDHT_RANDOM_WALK-910] | ||
469 | _ = x[MSG_WDHT_RANDOM_WALK_RESPONSE-911] | ||
470 | _ = x[MSG_WDHT_TRAIL_DESTROY-912] | ||
471 | _ = x[MSG_WDHT_TRAIL_ROUTE-913] | ||
472 | _ = x[MSG_WDHT_SUCCESSOR_FIND-914] | ||
473 | _ = x[MSG_WDHT_GET-915] | ||
474 | _ = x[MSG_WDHT_PUT-916] | ||
475 | _ = x[MSG_WDHT_GET_RESULT-917] | ||
476 | _ = x[MSG_RPS_PP_CHECK_LIVE-950] | ||
477 | _ = x[MSG_RPS_PP_PUSH-951] | ||
478 | _ = x[MSG_RPS_PP_PULL_REQUEST-952] | ||
479 | _ = x[MSG_RPS_PP_PULL_REPLY-953] | ||
480 | _ = x[MSG_RPS_CS_SEED-954] | ||
481 | _ = x[MSG_RPS_ACT_MALICIOUS-955] | ||
482 | _ = x[MSG_RPS_CS_SUB_START-956] | ||
483 | _ = x[MSG_RPS_CS_SUB_STOP-957] | ||
484 | _ = x[MSG_RECLAIM_ATTRIBUTE_STORE-961] | ||
485 | _ = x[MSG_RECLAIM_SUCCESS_RESPONSE-962] | ||
486 | _ = x[MSG_RECLAIM_ATTRIBUTE_ITERATION_START-963] | ||
487 | _ = x[MSG_RECLAIM_ATTRIBUTE_ITERATION_STOP-964] | ||
488 | _ = x[MSG_RECLAIM_ATTRIBUTE_ITERATION_NEXT-965] | ||
489 | _ = x[MSG_RECLAIM_ATTRIBUTE_RESULT-966] | ||
490 | _ = x[MSG_RECLAIM_ISSUE_TICKET-967] | ||
491 | _ = x[MSG_RECLAIM_TICKET_RESULT-968] | ||
492 | _ = x[MSG_RECLAIM_REVOKE_TICKET-969] | ||
493 | _ = x[MSG_RECLAIM_REVOKE_TICKET_RESULT-970] | ||
494 | _ = x[MSG_RECLAIM_CONSUME_TICKET-971] | ||
495 | _ = x[MSG_RECLAIM_CONSUME_TICKET_RESULT-972] | ||
496 | _ = x[MSG_RECLAIM_TICKET_ITERATION_START-973] | ||
497 | _ = x[MSG_RECLAIM_TICKET_ITERATION_STOP-974] | ||
498 | _ = x[MSG_RECLAIM_TICKET_ITERATION_NEXT-975] | ||
499 | _ = x[MSG_RECLAIM_ATTRIBUTE_DELETE-976] | ||
500 | _ = x[MSG_CREDENTIAL_VERIFY-981] | ||
501 | _ = x[MSG_CREDENTIAL_VERIFY_RESULT-982] | ||
502 | _ = x[MSG_CREDENTIAL_COLLECT-983] | ||
503 | _ = x[MSG_CREDENTIAL_COLLECT_RESULT-984] | ||
504 | _ = x[MSG_CADET_CONNECTION_CREATE-1000] | ||
505 | _ = x[MSG_CADET_CONNECTION_CREATE_ACK-1001] | ||
506 | _ = x[MSG_CADET_CONNECTION_BROKEN-1002] | ||
507 | _ = x[MSG_CADET_CONNECTION_DESTROY-1003] | ||
508 | _ = x[MSG_CADET_CONNECTION_PATH_CHANGED_UNIMPLEMENTED-1004] | ||
509 | _ = x[MSG_CADET_CONNECTION_HOP_BY_HOP_ENCRYPTED_ACK-1005] | ||
510 | _ = x[MSG_CADET_TUNNEL_ENCRYPTED_POLL-1006] | ||
511 | _ = x[MSG_CADET_TUNNEL_KX-1007] | ||
512 | _ = x[MSG_CADET_TUNNEL_ENCRYPTED-1008] | ||
513 | _ = x[MSG_CADET_TUNNEL_KX_AUTH-1009] | ||
514 | _ = x[MSG_CADET_CHANNEL_APP_DATA-1010] | ||
515 | _ = x[MSG_CADET_CHANNEL_APP_DATA_ACK-1011] | ||
516 | _ = x[MSG_CADET_CHANNEL_KEEPALIVE-1012] | ||
517 | _ = x[MSG_CADET_CHANNEL_OPEN-1013] | ||
518 | _ = x[MSG_CADET_CHANNEL_DESTROY-1014] | ||
519 | _ = x[MSG_CADET_CHANNEL_OPEN_ACK-1015] | ||
520 | _ = x[MSG_CADET_CHANNEL_OPEN_NACK_DEPRECATED-1016] | ||
521 | _ = x[MSG_CADET_LOCAL_DATA-1020] | ||
522 | _ = x[MSG_CADET_LOCAL_ACK-1021] | ||
523 | _ = x[MSG_CADET_LOCAL_PORT_OPEN-1022] | ||
524 | _ = x[MSG_CADET_LOCAL_PORT_CLOSE-1023] | ||
525 | _ = x[MSG_CADET_LOCAL_CHANNEL_CREATE-1024] | ||
526 | _ = x[MSG_CADET_LOCAL_CHANNEL_DESTROY-1025] | ||
527 | _ = x[MSG_CADET_LOCAL_REQUEST_INFO_CHANNEL-1030] | ||
528 | _ = x[MSG_CADET_LOCAL_INFO_CHANNEL-1031] | ||
529 | _ = x[MSG_CADET_LOCAL_INFO_CHANNEL_END-1032] | ||
530 | _ = x[MSG_CADET_LOCAL_REQUEST_INFO_PEERS-1033] | ||
531 | _ = x[MSG_CADET_LOCAL_INFO_PEERS-1034] | ||
532 | _ = x[MSG_CADET_LOCAL_INFO_PEERS_END-1035] | ||
533 | _ = x[MSG_CADET_LOCAL_REQUEST_INFO_PATH-1036] | ||
534 | _ = x[MSG_CADET_LOCAL_INFO_PATH-1037] | ||
535 | _ = x[MSG_CADET_LOCAL_INFO_PATH_END-1038] | ||
536 | _ = x[MSG_CADET_LOCAL_REQUEST_INFO_TUNNELS-1039] | ||
537 | _ = x[MSG_CADET_LOCAL_INFO_TUNNELS-1040] | ||
538 | _ = x[MSG_CADET_LOCAL_INFO_TUNNELS_END-1041] | ||
539 | _ = x[MSG_CADET_CLI-1059] | ||
540 | _ = x[MSG_NAT_REGISTER-1060] | ||
541 | _ = x[MSG_NAT_HANDLE_STUN-1061] | ||
542 | _ = x[MSG_NAT_REQUEST_CONNECTION_REVERSAL-1062] | ||
543 | _ = x[MSG_NAT_CONNECTION_REVERSAL_REQUESTED-1063] | ||
544 | _ = x[MSG_NAT_ADDRESS_CHANGE-1064] | ||
545 | _ = x[MSG_NAT_AUTO_REQUEST_CFG-1066] | ||
546 | _ = x[MSG_NAT_AUTO_CFG_RESULT-1065] | ||
547 | _ = x[MSG_AUCTION_CLIENT_CREATE-1110] | ||
548 | _ = x[MSG_AUCTION_CLIENT_JOIN-1111] | ||
549 | _ = x[MSG_AUCTION_CLIENT_OUTCOME-1112] | ||
550 | _ = x[MSG_RPS_CS_DEBUG_VIEW_REQUEST-1130] | ||
551 | _ = x[MSG_RPS_CS_DEBUG_VIEW_REPLY-1131] | ||
552 | _ = x[MSG_RPS_CS_DEBUG_VIEW_CANCEL-1132] | ||
553 | _ = x[MSG_RPS_CS_DEBUG_STREAM_REQUEST-1133] | ||
554 | _ = x[MSG_RPS_CS_DEBUG_STREAM_REPLY-1134] | ||
555 | _ = x[MSG_RPS_CS_DEBUG_STREAM_CANCEL-1135] | ||
556 | _ = x[MSG_ALL-65535] | ||
557 | } | ||
558 | |||
559 | 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_SEND_NACKMSG_DV_DISTANCE_CHANGEDMSG_DV_BOXMSG_TRANSPORT_XU_MESSAGEMSG_TRANSPORT_UDP_MESSAGEMSG_TRANSPORT_UDP_ACKMSG_TRANSPORT_TCP_NAT_PROBEMSG_TRANSPORT_TCP_WELCOMEMSG_TRANSPORT_ATSMSG_NAT_TESTMSG_CORE_INITMSG_CORE_INIT_REPLYMSG_CORE_NOTIFY_CONNECTMSG_CORE_NOTIFY_DISCONNECTMSG_CORE_NOTIFY_STATUS_CHANGEMSG_CORE_NOTIFY_INBOUNDMSG_CORE_NOTIFY_OUTBOUNDMSG_CORE_SEND_REQUESTMSG_CORE_SEND_READYMSG_CORE_SENDMSG_CORE_MONITOR_PEERSMSG_CORE_MONITOR_NOTIFYMSG_CORE_ENCRYPTED_MESSAGEMSG_CORE_PINGMSG_CORE_PONGMSG_CORE_HANGUPMSG_CORE_COMPRESSED_TYPE_MAPMSG_CORE_BINARY_TYPE_MAPMSG_CORE_EPHEMERAL_KEYMSG_CORE_CONFIRM_TYPE_MAPMSG_DATASTORE_RESERVEMSG_DATASTORE_RELEASE_RESERVEMSG_DATASTORE_STATUSMSG_DATASTORE_PUTMSG_DATASTORE_GETMSG_DATASTORE_GET_REPLICATIONMSG_DATASTORE_GET_ZERO_ANONYMITYMSG_DATASTORE_DATAMSG_DATASTORE_DATA_ENDMSG_DATASTORE_REMOVEMSG_DATASTORE_DROPMSG_DATASTORE_GET_KEYMSG_FS_REQUEST_LOC_SIGNMSG_FS_REQUEST_LOC_SIGNATUREMSG_FS_INDEX_STARTMSG_FS_INDEX_START_OKMSG_FS_INDEX_START_FAILEDMSG_FS_INDEX_LIST_GETMSG_FS_INDEX_LIST_ENTRYMSG_FS_INDEX_LIST_ENDMSG_FS_UNINDEXMSG_FS_UNINDEX_OKMSG_FS_START_SEARCHMSG_FS_GETMSG_FS_PUTMSG_FS_MIGRATION_STOPMSG_FS_CADET_QUERYMSG_FS_CADET_REPLYMSG_DHT_CLIENT_PUTMSG_DHT_CLIENT_GETMSG_DHT_CLIENT_GET_STOPMSG_DHT_CLIENT_RESULTMSG_DHT_P2P_PUTMSG_DHT_P2P_GETMSG_DHT_P2P_RESULTMSG_DHT_MONITOR_GETMSG_DHT_MONITOR_GET_RESPMSG_DHT_MONITOR_PUTMSG_DHT_MONITOR_PUT_RESPMSG_DHT_MONITOR_STARTMSG_DHT_MONITOR_STOPMSG_DHT_CLIENT_GET_RESULTS_KNOWNMSG_DHT_P2P_HELLOMSG_DHT_COREMSG_DHT_CLIENT_HELLO_URLMSG_HOSTLIST_ADVERTISEMENTMSG_DHT_CLIENT_HELLO_GETMSG_STATISTICS_SETMSG_STATISTICS_GETMSG_STATISTICS_VALUEMSG_STATISTICS_ENDMSG_STATISTICS_WATCHMSG_STATISTICS_WATCH_VALUEMSG_STATISTICS_DISCONNECTMSG_STATISTICS_DISCONNECT_CONFIRMMSG_VPN_HELPERMSG_VPN_ICMP_TO_SERVICEMSG_VPN_ICMP_TO_INTERNETMSG_VPN_ICMP_TO_VPNMSG_VPN_DNS_TO_INTERNETMSG_VPN_DNS_FROM_INTERNETMSG_VPN_TCP_TO_SERVICE_STARTMSG_VPN_TCP_TO_INTERNET_STARTMSG_VPN_TCP_DATA_TO_EXITMSG_VPN_TCP_DATA_TO_VPNMSG_VPN_UDP_TO_SERVICEMSG_VPN_UDP_TO_INTERNETMSG_VPN_UDP_REPLYMSG_VPN_CLIENT_REDIRECT_TO_IPMSG_VPN_CLIENT_REDIRECT_TO_SERVICEMSG_VPN_CLIENT_USE_IPMSG_DNS_CLIENT_INITMSG_DNS_CLIENT_REQUESTMSG_DNS_CLIENT_RESPONSEMSG_DNS_HELPERMSG_CHAT_JOIN_REQUESTMSG_CHAT_JOIN_NOTIFICATIONMSG_CHAT_LEAVE_NOTIFICATIONMSG_CHAT_MESSAGE_NOTIFICATIONMSG_CHAT_TRANSMIT_REQUESTMSG_CHAT_CONFIRMATION_RECEIPTMSG_CHAT_CONFIRMATION_NOTIFICATIONMSG_CHAT_P2P_JOIN_NOTIFICATIONMSG_CHAT_P2P_LEAVE_NOTIFICATIONMSG_CHAT_P2P_SYNC_REQUESTMSG_CHAT_P2P_MESSAGE_NOTIFICATIONMSG_CHAT_P2P_CONFIRMATION_RECEIPTMSG_NSE_STARTMSG_NSE_P2P_FLOODMSG_NSE_ESTIMATEMSG_PEERINFO_GETMSG_PEERINFO_GET_ALLMSG_PEERINFO_INFOMSG_PEERINFO_INFO_ENDMSG_PEERINFO_NOTIFYMSG_ATS_STARTMSG_ATS_REQUEST_ADDRESSMSG_ATS_REQUEST_ADDRESS_CANCELMSG_ATS_ADDRESS_UPDATEMSG_ATS_ADDRESS_DESTROYEDMSG_ATS_ADDRESS_SUGGESTIONMSG_ATS_PEER_INFORMATIONMSG_ATS_RESERVATION_REQUESTMSG_ATS_RESERVATION_RESULTMSG_ATS_PREFERENCE_CHANGEMSG_ATS_SESSION_RELEASEMSG_ATS_ADDRESS_ADDMSG_ATS_ADDRESSLIST_REQUESTMSG_ATS_ADDRESSLIST_RESPONSEMSG_ATS_PREFERENCE_FEEDBACKMSG_TRANSPORT_STARTMSG_TRANSPORT_CONNECTMSG_TRANSPORT_DISCONNECTMSG_TRANSPORT_SENDMSG_TRANSPORT_SEND_OKMSG_TRANSPORT_RECVMSG_TRANSPORT_SET_QUOTAMSG_TRANSPORT_ADDRESS_TO_STRINGMSG_TRANSPORT_ADDRESS_TO_STRING_REPLYMSG_TRANSPORT_BLACKLIST_INITMSG_TRANSPORT_BLACKLIST_QUERYMSG_TRANSPORT_BLACKLIST_REPLYMSG_TRANSPORT_PINGMSG_TRANSPORT_PONGMSG_TRANSPORT_SESSION_SYNMSG_TRANSPORT_SESSION_SYN_ACKMSG_TRANSPORT_SESSION_ACKMSG_TRANSPORT_SESSION_DISCONNECTMSG_TRANSPORT_SESSION_QUOTAMSG_TRANSPORT_MONITOR_PEER_REQUESTMSG_TRANSPORT_SESSION_KEEPALIVEMSG_TRANSPORT_SESSION_KEEPALIVE_RESPONSEMSG_TRANSPORT_MONITOR_PEER_RESPONSEMSG_TRANSPORT_BROADCAST_BEACONMSG_TRANSPORT_TRAFFIC_METRICMSG_TRANSPORT_MONITOR_PLUGIN_STARTMSG_TRANSPORT_MONITOR_PLUGIN_EVENTMSG_TRANSPORT_MONITOR_PLUGIN_SYNCMSG_TRANSPORT_MONITOR_PEER_RESPONSE_ENDMSG_FS_PUBLISH_HELPER_PROGRESS_FILEMSG_FS_PUBLISH_HELPER_PROGRESS_DIRECTORYMSG_FS_PUBLISH_HELPER_ERRORMSG_FS_PUBLISH_HELPER_SKIP_FILEMSG_FS_PUBLISH_HELPER_COUNTING_DONEMSG_FS_PUBLISH_HELPER_META_DATAMSG_FS_PUBLISH_HELPER_FINISHEDMSG_NAMECACHE_LOOKUP_BLOCKMSG_NAMECACHE_LOOKUP_BLOCK_RESPONSEMSG_NAMECACHE_BLOCK_CACHEMSG_NAMECACHE_BLOCK_CACHE_RESPONSEMSG_NAMESTORE_RECORD_STOREMSG_NAMESTORE_RECORD_STORE_RESPONSEMSG_NAMESTORE_RECORD_LOOKUPMSG_NAMESTORE_RECORD_LOOKUP_RESPONSEMSG_NAMESTORE_ZONE_TO_NAMEMSG_NAMESTORE_ZONE_TO_NAME_RESPONSEMSG_NAMESTORE_MONITOR_STARTMSG_NAMESTORE_MONITOR_SYNCMSG_NAMESTORE_RECORD_RESULTMSG_NAMESTORE_MONITOR_NEXTMSG_NAMESTORE_ZONE_ITERATION_STARTMSG_NAMESTORE_ZONE_ITERATION_NEXTMSG_NAMESTORE_ZONE_ITERATION_STOPMSG_TESTBED_INITMSG_TESTBED_ADD_HOSTMSG_TESTBED_ADD_HOST_SUCCESSMSG_TESTBED_LINK_CONTROLLERSMSG_TESTBED_CREATE_PEERMSG_TESTBED_RECONFIGURE_PEERMSG_TESTBED_START_PEERMSG_TESTBED_STOP_PEERMSG_TESTBED_DESTROY_PEERMSG_TESTBED_CONFIGURE_UNDERLAY_LINKMSG_TESTBED_OVERLAY_CONNECTMSG_TESTBED_PEER_EVENTMSG_TESTBED_PEER_CONNECT_EVENTMSG_TESTBED_OPERATION_FAIL_EVENTMSG_TESTBED_CREATE_PEER_SUCCESSMSG_TESTBED_GENERIC_OPERATION_SUCCESSMSG_TESTBED_GET_PEER_INFORMATIONMSG_TESTBED_PEER_INFORMATIONMSG_TESTBED_REMOTE_OVERLAY_CONNECTMSG_TESTBED_GET_SLAVE_CONFIGURATIONMSG_TESTBED_SLAVE_CONFIGURATIONMSG_TESTBED_LINK_CONTROLLERS_RESULTMSG_TESTBED_SHUTDOWN_PEERSMSG_TESTBED_MANAGE_PEER_SERVICEMSG_TESTBED_BARRIER_INITMSG_TESTBED_BARRIER_CANCELMSG_TESTBED_BARRIER_STATUSMSG_TESTBED_BARRIER_WAITMSG_TESTBED_MAXMSG_TESTBED_HELPER_INITMSG_TESTBED_HELPER_REPLYMSG_GNS_LOOKUPMSG_GNS_LOOKUP_RESULTMSG_GNS_REVERSE_LOOKUPMSG_GNS_REVERSE_LOOKUP_RESULTMSG_CONSENSUS_CLIENT_JOINMSG_CONSENSUS_CLIENT_INSERTMSG_CONSENSUS_CLIENT_BEGINMSG_CONSENSUS_CLIENT_RECEIVED_ELEMENTMSG_CONSENSUS_CLIENT_CONCLUDEMSG_CONSENSUS_CLIENT_CONCLUDE_DONEMSG_CONSENSUS_CLIENT_ACKMSG_CONSENSUS_P2P_DELTA_ESTIMATEMSG_CONSENSUS_P2P_DIFFERENCE_DIGESTMSG_CONSENSUS_P2P_ELEMENTSMSG_CONSENSUS_P2P_ELEMENTS_REQUESTMSG_CONSENSUS_P2P_ELEMENTS_REPORTMSG_CONSENSUS_P2P_HELLOMSG_CONSENSUS_P2P_SYNCEDMSG_CONSENSUS_P2P_FINMSG_SET_UNION_P2P_REQUEST_FULLMSG_SET_UNION_P2P_DEMANDMSG_SET_UNION_P2P_INQUIRYMSG_SET_UNION_P2P_OFFERMSG_SET_REJECTMSG_SET_CANCELMSG_SET_ITER_ACKMSG_SET_RESULTMSG_SET_ADDMSG_SET_REMOVEMSG_SET_LISTENMSG_SET_ACCEPTMSG_SET_EVALUATEMSG_SET_CONCLUDEMSG_SET_REQUESTMSG_SET_CREATEMSG_SET_P2P_OPERATION_REQUESTMSG_SET_UNION_P2P_SEMSG_SET_UNION_P2P_IBFMSG_SET_P2P_ELEMENTSMSG_SET_P2P_ELEMENT_REQUESTSMSG_SET_UNION_P2P_DONEMSG_SET_ITER_REQUESTMSG_SET_ITER_ELEMENTMSG_SET_ITER_DONEMSG_SET_UNION_P2P_SECMSG_SET_INTERSECTION_P2P_ELEMENT_INFOMSG_SET_INTERSECTION_P2P_BFMSG_SET_INTERSECTION_P2P_DONEMSG_SET_COPY_LAZY_PREPAREMSG_SET_COPY_LAZY_RESPONSEMSG_SET_COPY_LAZY_CONNECTMSG_SET_UNION_P2P_FULL_DONEMSG_SET_UNION_P2P_FULL_ELEMENTMSG_SET_UNION_P2P_OVERMSG_TESTBED_LOGGER_MSGMSG_TESTBED_LOGGER_ACKMSG_REGEX_ANNOUNCEMSG_REGEX_SEARCHMSG_REGEX_RESULTMSG_IDENTITY_STARTMSG_IDENTITY_RESULT_CODEMSG_IDENTITY_UPDATEMSG_IDENTITY_GET_DEFAULTMSG_IDENTITY_SET_DEFAULTMSG_IDENTITY_CREATEMSG_IDENTITY_RENAMEMSG_IDENTITY_DELETEMSG_IDENTITY_LOOKUPMSG_IDENTITY_LOOKUP_BY_NAMEMSG_REVOCATION_QUERYMSG_REVOCATION_QUERY_RESPONSEMSG_REVOCATION_REVOKEMSG_REVOCATION_REVOKE_RESPONSEMSG_SCALARPRODUCT_CLIENT_TO_ALICEMSG_SCALARPRODUCT_CLIENT_TO_BOBMSG_SCALARPRODUCT_CLIENT_MULTIPART_ALICEMSG_SCALARPRODUCT_CLIENT_MULTIPART_BOBMSG_SCALARPRODUCT_SESSION_INITIALIZATIONMSG_SCALARPRODUCT_ALICE_CRYPTODATAMSG_SCALARPRODUCT_BOB_CRYPTODATAMSG_SCALARPRODUCT_BOB_CRYPTODATA_MULTIPARTMSG_SCALARPRODUCT_RESULTMSG_SCALARPRODUCT_ECC_SESSION_INITIALIZATIONMSG_SCALARPRODUCT_ECC_ALICE_CRYPTODATAMSG_SCALARPRODUCT_ECC_BOB_CRYPTODATAMSG_PSYCSTORE_MEMBERSHIP_STOREMSG_PSYCSTORE_MEMBERSHIP_TESTMSG_PSYCSTORE_FRAGMENT_STOREMSG_PSYCSTORE_FRAGMENT_GETMSG_PSYCSTORE_MESSAGE_GETMSG_PSYCSTORE_MESSAGE_GET_FRAGMENTMSG_PSYCSTORE_COUNTERS_GETMSG_PSYCSTORE_STATE_MODIFYMSG_PSYCSTORE_STATE_SYNCMSG_PSYCSTORE_STATE_RESETMSG_PSYCSTORE_STATE_HASH_UPDATEMSG_PSYCSTORE_STATE_GETMSG_PSYCSTORE_STATE_GET_PREFIXMSG_PSYCSTORE_RESULT_CODEMSG_PSYCSTORE_RESULT_FRAGMENTMSG_PSYCSTORE_RESULT_COUNTERSMSG_PSYCSTORE_RESULT_STATEMSG_PSYC_RESULT_CODEMSG_PSYC_MASTER_STARTMSG_PSYC_MASTER_START_ACKMSG_PSYC_SLAVE_JOINMSG_PSYC_SLAVE_JOIN_ACKMSG_PSYC_PART_REQUESTMSG_PSYC_PART_ACKMSG_PSYC_JOIN_REQUESTMSG_PSYC_JOIN_DECISIONMSG_PSYC_CHANNEL_MEMBERSHIP_STOREMSG_PSYC_MESSAGEMSG_PSYC_MESSAGE_HEADERMSG_PSYC_MESSAGE_METHODMSG_PSYC_MESSAGE_MODIFIERMSG_PSYC_MESSAGE_MOD_CONTMSG_PSYC_MESSAGE_DATAMSG_PSYC_MESSAGE_ENDMSG_PSYC_MESSAGE_CANCELMSG_PSYC_MESSAGE_ACKMSG_PSYC_HISTORY_REPLAYMSG_PSYC_HISTORY_RESULTMSG_PSYC_STATE_GETMSG_PSYC_STATE_GET_PREFIXMSG_PSYC_STATE_RESULTMSG_CONVERSATION_AUDIOMSG_CONVERSATION_CS_PHONE_REGISTERMSG_CONVERSATION_CS_PHONE_PICK_UPMSG_CONVERSATION_CS_PHONE_HANG_UPMSG_CONVERSATION_CS_PHONE_CALLMSG_CONVERSATION_CS_PHONE_RINGMSG_CONVERSATION_CS_PHONE_SUSPENDMSG_CONVERSATION_CS_PHONE_RESUMEMSG_CONVERSATION_CS_PHONE_PICKED_UPMSG_CONVERSATION_CS_AUDIOMSG_CONVERSATION_CADET_PHONE_RINGMSG_CONVERSATION_CADET_PHONE_HANG_UPMSG_CONVERSATION_CADET_PHONE_PICK_UPMSG_CONVERSATION_CADET_PHONE_SUSPENDMSG_CONVERSATION_CADET_PHONE_RESUMEMSG_CONVERSATION_CADET_AUDIOMSG_MULTICAST_ORIGIN_STARTMSG_MULTICAST_MEMBER_JOINMSG_MULTICAST_JOIN_REQUESTMSG_MULTICAST_JOIN_DECISIONMSG_MULTICAST_PART_REQUESTMSG_MULTICAST_PART_ACKMSG_MULTICAST_GROUP_ENDMSG_MULTICAST_MESSAGEMSG_MULTICAST_REQUESTMSG_MULTICAST_FRAGMENT_ACKMSG_MULTICAST_REPLAY_REQUESTMSG_MULTICAST_REPLAY_RESPONSEMSG_MULTICAST_REPLAY_RESPONSE_ENDMSG_SECRETSHARING_CLIENT_GENERATEMSG_SECRETSHARING_CLIENT_DECRYPTMSG_SECRETSHARING_CLIENT_DECRYPT_DONEMSG_SECRETSHARING_CLIENT_SECRET_READYMSG_PEERSTORE_STOREMSG_PEERSTORE_ITERATEMSG_PEERSTORE_ITERATE_RECORDMSG_PEERSTORE_ITERATE_ENDMSG_PEERSTORE_WATCHMSG_PEERSTORE_WATCH_RECORDMSG_PEERSTORE_WATCH_CANCELMSG_SOCIAL_RESULT_CODEMSG_SOCIAL_HOST_ENTERMSG_SOCIAL_HOST_ENTER_ACKMSG_SOCIAL_GUEST_ENTERMSG_SOCIAL_GUEST_ENTER_BY_NAMEMSG_SOCIAL_GUEST_ENTER_ACKMSG_SOCIAL_ENTRY_REQUESTMSG_SOCIAL_ENTRY_DECISIONMSG_SOCIAL_PLACE_LEAVEMSG_SOCIAL_PLACE_LEAVE_ACKMSG_SOCIAL_ZONE_ADD_PLACEMSG_SOCIAL_ZONE_ADD_NYMMSG_SOCIAL_APP_CONNECTMSG_SOCIAL_APP_DETACHMSG_SOCIAL_APP_EGOMSG_SOCIAL_APP_EGO_ENDMSG_SOCIAL_APP_PLACEMSG_SOCIAL_APP_PLACE_ENDMSG_SOCIAL_MSG_PROC_SETMSG_SOCIAL_MSG_PROC_CLEARMSG_XDHT_P2P_TRAIL_SETUPMSG_XDHT_P2P_TRAIL_SETUP_RESULTMSG_XDHT_P2P_VERIFY_SUCCESSORMSG_XDHT_P2P_NOTIFY_NEW_SUCCESSORMSG_XDHT_P2P_VERIFY_SUCCESSOR_RESULTMSG_XDHT_P2P_GET_RESULTMSG_XDHT_P2P_TRAIL_SETUP_REJECTIONMSG_XDHT_P2P_TRAIL_TEARDOWNMSG_XDHT_P2P_ADD_TRAILMSG_XDHT_P2P_PUTMSG_XDHT_P2P_GETMSG_XDHT_P2P_NOTIFY_SUCCESSOR_CONFIRMATIONMSG_DHT_ACT_MALICIOUSMSG_DHT_CLIENT_ACT_MALICIOUS_OKMSG_WDHT_RANDOM_WALKMSG_WDHT_RANDOM_WALK_RESPONSEMSG_WDHT_TRAIL_DESTROYMSG_WDHT_TRAIL_ROUTEMSG_WDHT_SUCCESSOR_FINDMSG_WDHT_GETMSG_WDHT_PUTMSG_WDHT_GET_RESULTMSG_RPS_PP_CHECK_LIVEMSG_RPS_PP_PUSHMSG_RPS_PP_PULL_REQUESTMSG_RPS_PP_PULL_REPLYMSG_RPS_CS_SEEDMSG_RPS_ACT_MALICIOUSMSG_RPS_CS_SUB_STARTMSG_RPS_CS_SUB_STOPMSG_RECLAIM_ATTRIBUTE_STOREMSG_RECLAIM_SUCCESS_RESPONSEMSG_RECLAIM_ATTRIBUTE_ITERATION_STARTMSG_RECLAIM_ATTRIBUTE_ITERATION_STOPMSG_RECLAIM_ATTRIBUTE_ITERATION_NEXTMSG_RECLAIM_ATTRIBUTE_RESULTMSG_RECLAIM_ISSUE_TICKETMSG_RECLAIM_TICKET_RESULTMSG_RECLAIM_REVOKE_TICKETMSG_RECLAIM_REVOKE_TICKET_RESULTMSG_RECLAIM_CONSUME_TICKETMSG_RECLAIM_CONSUME_TICKET_RESULTMSG_RECLAIM_TICKET_ITERATION_STARTMSG_RECLAIM_TICKET_ITERATION_STOPMSG_RECLAIM_TICKET_ITERATION_NEXTMSG_RECLAIM_ATTRIBUTE_DELETEMSG_CREDENTIAL_VERIFYMSG_CREDENTIAL_VERIFY_RESULTMSG_CREDENTIAL_COLLECTMSG_CREDENTIAL_COLLECT_RESULTMSG_CADET_CONNECTION_CREATEMSG_CADET_CONNECTION_CREATE_ACKMSG_CADET_CONNECTION_BROKENMSG_CADET_CONNECTION_DESTROYMSG_CADET_CONNECTION_PATH_CHANGED_UNIMPLEMENTEDMSG_CADET_CONNECTION_HOP_BY_HOP_ENCRYPTED_ACKMSG_CADET_TUNNEL_ENCRYPTED_POLLMSG_CADET_TUNNEL_KXMSG_CADET_TUNNEL_ENCRYPTEDMSG_CADET_TUNNEL_KX_AUTHMSG_CADET_CHANNEL_APP_DATAMSG_CADET_CHANNEL_APP_DATA_ACKMSG_CADET_CHANNEL_KEEPALIVEMSG_CADET_CHANNEL_OPENMSG_CADET_CHANNEL_DESTROYMSG_CADET_CHANNEL_OPEN_ACKMSG_CADET_CHANNEL_OPEN_NACK_DEPRECATEDMSG_CADET_LOCAL_DATAMSG_CADET_LOCAL_ACKMSG_CADET_LOCAL_PORT_OPENMSG_CADET_LOCAL_PORT_CLOSEMSG_CADET_LOCAL_CHANNEL_CREATEMSG_CADET_LOCAL_CHANNEL_DESTROYMSG_CADET_LOCAL_REQUEST_INFO_CHANNELMSG_CADET_LOCAL_INFO_CHANNELMSG_CADET_LOCAL_INFO_CHANNEL_ENDMSG_CADET_LOCAL_REQUEST_INFO_PEERSMSG_CADET_LOCAL_INFO_PEERSMSG_CADET_LOCAL_INFO_PEERS_ENDMSG_CADET_LOCAL_REQUEST_INFO_PATHMSG_CADET_LOCAL_INFO_PATHMSG_CADET_LOCAL_INFO_PATH_ENDMSG_CADET_LOCAL_REQUEST_INFO_TUNNELSMSG_CADET_LOCAL_INFO_TUNNELSMSG_CADET_LOCAL_INFO_TUNNELS_ENDMSG_CADET_CLIMSG_NAT_REGISTERMSG_NAT_HANDLE_STUNMSG_NAT_REQUEST_CONNECTION_REVERSALMSG_NAT_CONNECTION_REVERSAL_REQUESTEDMSG_NAT_ADDRESS_CHANGEMSG_NAT_AUTO_CFG_RESULTMSG_NAT_AUTO_REQUEST_CFGMSG_AUCTION_CLIENT_CREATEMSG_AUCTION_CLIENT_JOINMSG_AUCTION_CLIENT_OUTCOMEMSG_RPS_CS_DEBUG_VIEW_REQUESTMSG_RPS_CS_DEBUG_VIEW_REPLYMSG_RPS_CS_DEBUG_VIEW_CANCELMSG_RPS_CS_DEBUG_STREAM_REQUESTMSG_RPS_CS_DEBUG_STREAM_REPLYMSG_RPS_CS_DEBUG_STREAM_CANCELMSG_ALL" | ||
560 | |||
561 | var _MsgType_map = map[MsgType]string{ | ||
562 | 1: _MsgType_name[0:8], | ||
563 | 2: _MsgType_name[8:17], | ||
564 | 3: _MsgType_name[17:27], | ||
565 | 4: _MsgType_name[27:47], | ||
566 | 5: _MsgType_name[47:68], | ||
567 | 6: _MsgType_name[68:84], | ||
568 | 7: _MsgType_name[84:101], | ||
569 | 8: _MsgType_name[101:114], | ||
570 | 9: _MsgType_name[114:126], | ||
571 | 10: _MsgType_name[126:140], | ||
572 | 11: _MsgType_name[140:154], | ||
573 | 12: _MsgType_name[154:166], | ||
574 | 13: _MsgType_name[166:185], | ||
575 | 14: _MsgType_name[185:200], | ||
576 | 15: _MsgType_name[200:212], | ||
577 | 16: _MsgType_name[212:228], | ||
578 | 17: _MsgType_name[228:237], | ||
579 | 18: _MsgType_name[237:249], | ||
580 | 19: _MsgType_name[249:265], | ||
581 | 39: _MsgType_name[265:288], | ||
582 | 40: _MsgType_name[288:313], | ||
583 | 41: _MsgType_name[313:336], | ||
584 | 42: _MsgType_name[336:358], | ||
585 | 43: _MsgType_name[358:371], | ||
586 | 44: _MsgType_name[371:382], | ||
587 | 45: _MsgType_name[382:393], | ||
588 | 46: _MsgType_name[393:408], | ||
589 | 47: _MsgType_name[408:420], | ||
590 | 48: _MsgType_name[420:432], | ||
591 | 49: _MsgType_name[432:446], | ||
592 | 50: _MsgType_name[446:463], | ||
593 | 51: _MsgType_name[463:479], | ||
594 | 52: _MsgType_name[479:502], | ||
595 | 53: _MsgType_name[502:512], | ||
596 | 55: _MsgType_name[512:536], | ||
597 | 56: _MsgType_name[536:561], | ||
598 | 57: _MsgType_name[561:582], | ||
599 | 60: _MsgType_name[582:609], | ||
600 | 61: _MsgType_name[609:634], | ||
601 | 62: _MsgType_name[634:651], | ||
602 | 63: _MsgType_name[651:663], | ||
603 | 64: _MsgType_name[663:676], | ||
604 | 65: _MsgType_name[676:695], | ||
605 | 67: _MsgType_name[695:718], | ||
606 | 68: _MsgType_name[718:744], | ||
607 | 69: _MsgType_name[744:773], | ||
608 | 70: _MsgType_name[773:796], | ||
609 | 71: _MsgType_name[796:820], | ||
610 | 74: _MsgType_name[820:841], | ||
611 | 75: _MsgType_name[841:860], | ||
612 | 76: _MsgType_name[860:873], | ||
613 | 78: _MsgType_name[873:895], | ||
614 | 79: _MsgType_name[895:918], | ||
615 | 82: _MsgType_name[918:944], | ||
616 | 83: _MsgType_name[944:957], | ||
617 | 84: _MsgType_name[957:970], | ||
618 | 85: _MsgType_name[970:985], | ||
619 | 86: _MsgType_name[985:1013], | ||
620 | 87: _MsgType_name[1013:1037], | ||
621 | 88: _MsgType_name[1037:1059], | ||
622 | 89: _MsgType_name[1059:1084], | ||
623 | 92: _MsgType_name[1084:1105], | ||
624 | 93: _MsgType_name[1105:1134], | ||
625 | 94: _MsgType_name[1134:1154], | ||
626 | 95: _MsgType_name[1154:1171], | ||
627 | 97: _MsgType_name[1171:1188], | ||
628 | 98: _MsgType_name[1188:1217], | ||
629 | 99: _MsgType_name[1217:1249], | ||
630 | 100: _MsgType_name[1249:1267], | ||
631 | 101: _MsgType_name[1267:1289], | ||
632 | 102: _MsgType_name[1289:1309], | ||
633 | 103: _MsgType_name[1309:1327], | ||
634 | 104: _MsgType_name[1327:1348], | ||
635 | 126: _MsgType_name[1348:1371], | ||
636 | 127: _MsgType_name[1371:1399], | ||
637 | 128: _MsgType_name[1399:1417], | ||
638 | 129: _MsgType_name[1417:1438], | ||
639 | 130: _MsgType_name[1438:1463], | ||
640 | 131: _MsgType_name[1463:1484], | ||
641 | 132: _MsgType_name[1484:1507], | ||
642 | 133: _MsgType_name[1507:1528], | ||
643 | 134: _MsgType_name[1528:1542], | ||
644 | 135: _MsgType_name[1542:1559], | ||
645 | 136: _MsgType_name[1559:1578], | ||
646 | 137: _MsgType_name[1578:1588], | ||
647 | 138: _MsgType_name[1588:1598], | ||
648 | 139: _MsgType_name[1598:1619], | ||
649 | 140: _MsgType_name[1619:1637], | ||
650 | 141: _MsgType_name[1637:1655], | ||
651 | 142: _MsgType_name[1655:1673], | ||
652 | 143: _MsgType_name[1673:1691], | ||
653 | 144: _MsgType_name[1691:1714], | ||
654 | 145: _MsgType_name[1714:1735], | ||
655 | 146: _MsgType_name[1735:1750], | ||
656 | 147: _MsgType_name[1750:1765], | ||
657 | 148: _MsgType_name[1765:1783], | ||
658 | 149: _MsgType_name[1783:1802], | ||
659 | 150: _MsgType_name[1802:1826], | ||
660 | 151: _MsgType_name[1826:1845], | ||
661 | 152: _MsgType_name[1845:1869], | ||
662 | 153: _MsgType_name[1869:1890], | ||
663 | 154: _MsgType_name[1890:1910], | ||
664 | 156: _MsgType_name[1910:1942], | ||
665 | 157: _MsgType_name[1942:1959], | ||
666 | 158: _MsgType_name[1959:1971], | ||
667 | 159: _MsgType_name[1971:1995], | ||
668 | 160: _MsgType_name[1995:2021], | ||
669 | 161: _MsgType_name[2021:2045], | ||
670 | 168: _MsgType_name[2045:2063], | ||
671 | 169: _MsgType_name[2063:2081], | ||
672 | 170: _MsgType_name[2081:2101], | ||
673 | 171: _MsgType_name[2101:2119], | ||
674 | 172: _MsgType_name[2119:2139], | ||
675 | 173: _MsgType_name[2139:2165], | ||
676 | 174: _MsgType_name[2165:2190], | ||
677 | 175: _MsgType_name[2190:2223], | ||
678 | 185: _MsgType_name[2223:2237], | ||
679 | 190: _MsgType_name[2237:2260], | ||
680 | 191: _MsgType_name[2260:2284], | ||
681 | 192: _MsgType_name[2284:2303], | ||
682 | 193: _MsgType_name[2303:2326], | ||
683 | 194: _MsgType_name[2326:2351], | ||
684 | 195: _MsgType_name[2351:2379], | ||
685 | 196: _MsgType_name[2379:2408], | ||
686 | 197: _MsgType_name[2408:2432], | ||
687 | 198: _MsgType_name[2432:2455], | ||
688 | 199: _MsgType_name[2455:2477], | ||
689 | 200: _MsgType_name[2477:2500], | ||
690 | 201: _MsgType_name[2500:2517], | ||
691 | 202: _MsgType_name[2517:2546], | ||
692 | 203: _MsgType_name[2546:2580], | ||
693 | 204: _MsgType_name[2580:2601], | ||
694 | 211: _MsgType_name[2601:2620], | ||
695 | 212: _MsgType_name[2620:2642], | ||
696 | 213: _MsgType_name[2642:2665], | ||
697 | 214: _MsgType_name[2665:2679], | ||
698 | 300: _MsgType_name[2679:2700], | ||
699 | 301: _MsgType_name[2700:2726], | ||
700 | 302: _MsgType_name[2726:2753], | ||
701 | 303: _MsgType_name[2753:2782], | ||
702 | 304: _MsgType_name[2782:2807], | ||
703 | 305: _MsgType_name[2807:2836], | ||
704 | 306: _MsgType_name[2836:2870], | ||
705 | 307: _MsgType_name[2870:2900], | ||
706 | 308: _MsgType_name[2900:2931], | ||
707 | 309: _MsgType_name[2931:2956], | ||
708 | 310: _MsgType_name[2956:2989], | ||
709 | 311: _MsgType_name[2989:3022], | ||
710 | 321: _MsgType_name[3022:3035], | ||
711 | 322: _MsgType_name[3035:3052], | ||
712 | 323: _MsgType_name[3052:3068], | ||
713 | 330: _MsgType_name[3068:3084], | ||
714 | 331: _MsgType_name[3084:3104], | ||
715 | 332: _MsgType_name[3104:3121], | ||
716 | 333: _MsgType_name[3121:3142], | ||
717 | 334: _MsgType_name[3142:3161], | ||
718 | 340: _MsgType_name[3161:3174], | ||
719 | 341: _MsgType_name[3174:3197], | ||
720 | 342: _MsgType_name[3197:3227], | ||
721 | 343: _MsgType_name[3227:3249], | ||
722 | 344: _MsgType_name[3249:3274], | ||
723 | 345: _MsgType_name[3274:3300], | ||
724 | 346: _MsgType_name[3300:3324], | ||
725 | 347: _MsgType_name[3324:3351], | ||
726 | 348: _MsgType_name[3351:3377], | ||
727 | 349: _MsgType_name[3377:3402], | ||
728 | 350: _MsgType_name[3402:3425], | ||
729 | 353: _MsgType_name[3425:3444], | ||
730 | 354: _MsgType_name[3444:3471], | ||
731 | 355: _MsgType_name[3471:3499], | ||
732 | 356: _MsgType_name[3499:3526], | ||
733 | 360: _MsgType_name[3526:3545], | ||
734 | 361: _MsgType_name[3545:3566], | ||
735 | 362: _MsgType_name[3566:3590], | ||
736 | 363: _MsgType_name[3590:3608], | ||
737 | 364: _MsgType_name[3608:3629], | ||
738 | 365: _MsgType_name[3629:3647], | ||
739 | 366: _MsgType_name[3647:3670], | ||
740 | 367: _MsgType_name[3670:3701], | ||
741 | 368: _MsgType_name[3701:3738], | ||
742 | 369: _MsgType_name[3738:3766], | ||
743 | 370: _MsgType_name[3766:3795], | ||
744 | 371: _MsgType_name[3795:3824], | ||
745 | 372: _MsgType_name[3824:3842], | ||
746 | 373: _MsgType_name[3842:3860], | ||
747 | 375: _MsgType_name[3860:3885], | ||
748 | 376: _MsgType_name[3885:3914], | ||
749 | 377: _MsgType_name[3914:3939], | ||
750 | 378: _MsgType_name[3939:3971], | ||
751 | 379: _MsgType_name[3971:3998], | ||
752 | 380: _MsgType_name[3998:4032], | ||
753 | 381: _MsgType_name[4032:4063], | ||
754 | 382: _MsgType_name[4063:4103], | ||
755 | 383: _MsgType_name[4103:4138], | ||
756 | 384: _MsgType_name[4138:4168], | ||
757 | 385: _MsgType_name[4168:4196], | ||
758 | 388: _MsgType_name[4196:4230], | ||
759 | 389: _MsgType_name[4230:4264], | ||
760 | 390: _MsgType_name[4264:4297], | ||
761 | 391: _MsgType_name[4297:4336], | ||
762 | 420: _MsgType_name[4336:4371], | ||
763 | 421: _MsgType_name[4371:4411], | ||
764 | 422: _MsgType_name[4411:4438], | ||
765 | 423: _MsgType_name[4438:4469], | ||
766 | 424: _MsgType_name[4469:4504], | ||
767 | 425: _MsgType_name[4504:4535], | ||
768 | 426: _MsgType_name[4535:4565], | ||
769 | 431: _MsgType_name[4565:4591], | ||
770 | 432: _MsgType_name[4591:4626], | ||
771 | 433: _MsgType_name[4626:4651], | ||
772 | 434: _MsgType_name[4651:4685], | ||
773 | 435: _MsgType_name[4685:4711], | ||
774 | 436: _MsgType_name[4711:4746], | ||
775 | 437: _MsgType_name[4746:4773], | ||
776 | 438: _MsgType_name[4773:4809], | ||
777 | 439: _MsgType_name[4809:4835], | ||
778 | 440: _MsgType_name[4835:4870], | ||
779 | 441: _MsgType_name[4870:4897], | ||
780 | 442: _MsgType_name[4897:4923], | ||
781 | 443: _MsgType_name[4923:4950], | ||
782 | 444: _MsgType_name[4950:4976], | ||
783 | 445: _MsgType_name[4976:5010], | ||
784 | 447: _MsgType_name[5010:5043], | ||
785 | 448: _MsgType_name[5043:5076], | ||
786 | 460: _MsgType_name[5076:5092], | ||
787 | 461: _MsgType_name[5092:5112], | ||
788 | 462: _MsgType_name[5112:5140], | ||
789 | 463: _MsgType_name[5140:5168], | ||
790 | 464: _MsgType_name[5168:5191], | ||
791 | 465: _MsgType_name[5191:5219], | ||
792 | 466: _MsgType_name[5219:5241], | ||
793 | 467: _MsgType_name[5241:5262], | ||
794 | 468: _MsgType_name[5262:5286], | ||
795 | 469: _MsgType_name[5286:5321], | ||
796 | 470: _MsgType_name[5321:5348], | ||
797 | 471: _MsgType_name[5348:5370], | ||
798 | 472: _MsgType_name[5370:5400], | ||
799 | 473: _MsgType_name[5400:5432], | ||
800 | 474: _MsgType_name[5432:5463], | ||
801 | 475: _MsgType_name[5463:5500], | ||
802 | 476: _MsgType_name[5500:5532], | ||
803 | 477: _MsgType_name[5532:5560], | ||
804 | 478: _MsgType_name[5560:5594], | ||
805 | 479: _MsgType_name[5594:5629], | ||
806 | 480: _MsgType_name[5629:5660], | ||
807 | 481: _MsgType_name[5660:5695], | ||
808 | 482: _MsgType_name[5695:5721], | ||
809 | 483: _MsgType_name[5721:5752], | ||
810 | 484: _MsgType_name[5752:5776], | ||
811 | 485: _MsgType_name[5776:5802], | ||
812 | 486: _MsgType_name[5802:5828], | ||
813 | 487: _MsgType_name[5828:5852], | ||
814 | 488: _MsgType_name[5852:5867], | ||
815 | 495: _MsgType_name[5867:5890], | ||
816 | 496: _MsgType_name[5890:5914], | ||
817 | 500: _MsgType_name[5914:5928], | ||
818 | 501: _MsgType_name[5928:5949], | ||
819 | 502: _MsgType_name[5949:5971], | ||
820 | 503: _MsgType_name[5971:6000], | ||
821 | 520: _MsgType_name[6000:6025], | ||
822 | 521: _MsgType_name[6025:6052], | ||
823 | 522: _MsgType_name[6052:6078], | ||
824 | 523: _MsgType_name[6078:6115], | ||
825 | 524: _MsgType_name[6115:6144], | ||
826 | 525: _MsgType_name[6144:6178], | ||
827 | 540: _MsgType_name[6178:6202], | ||
828 | 541: _MsgType_name[6202:6234], | ||
829 | 542: _MsgType_name[6234:6269], | ||
830 | 543: _MsgType_name[6269:6295], | ||
831 | 544: _MsgType_name[6295:6329], | ||
832 | 545: _MsgType_name[6329:6362], | ||
833 | 546: _MsgType_name[6362:6385], | ||
834 | 547: _MsgType_name[6385:6409], | ||
835 | 548: _MsgType_name[6409:6430], | ||
836 | 565: _MsgType_name[6430:6460], | ||
837 | 566: _MsgType_name[6460:6484], | ||
838 | 567: _MsgType_name[6484:6509], | ||
839 | 568: _MsgType_name[6509:6532], | ||
840 | 569: _MsgType_name[6532:6546], | ||
841 | 570: _MsgType_name[6546:6560], | ||
842 | 571: _MsgType_name[6560:6576], | ||
843 | 572: _MsgType_name[6576:6590], | ||
844 | 573: _MsgType_name[6590:6601], | ||
845 | 574: _MsgType_name[6601:6615], | ||
846 | 575: _MsgType_name[6615:6629], | ||
847 | 576: _MsgType_name[6629:6643], | ||
848 | 577: _MsgType_name[6643:6659], | ||
849 | 578: _MsgType_name[6659:6675], | ||
850 | 579: _MsgType_name[6675:6690], | ||
851 | 580: _MsgType_name[6690:6704], | ||
852 | 581: _MsgType_name[6704:6733], | ||
853 | 582: _MsgType_name[6733:6753], | ||
854 | 583: _MsgType_name[6753:6774], | ||
855 | 584: _MsgType_name[6774:6794], | ||
856 | 585: _MsgType_name[6794:6822], | ||
857 | 586: _MsgType_name[6822:6844], | ||
858 | 587: _MsgType_name[6844:6864], | ||
859 | 588: _MsgType_name[6864:6884], | ||
860 | 589: _MsgType_name[6884:6901], | ||
861 | 590: _MsgType_name[6901:6922], | ||
862 | 591: _MsgType_name[6922:6959], | ||
863 | 592: _MsgType_name[6959:6986], | ||
864 | 593: _MsgType_name[6986:7015], | ||
865 | 594: _MsgType_name[7015:7040], | ||
866 | 595: _MsgType_name[7040:7066], | ||
867 | 596: _MsgType_name[7066:7091], | ||
868 | 597: _MsgType_name[7091:7118], | ||
869 | 598: _MsgType_name[7118:7148], | ||
870 | 599: _MsgType_name[7148:7170], | ||
871 | 600: _MsgType_name[7170:7192], | ||
872 | 601: _MsgType_name[7192:7214], | ||
873 | 620: _MsgType_name[7214:7232], | ||
874 | 621: _MsgType_name[7232:7248], | ||
875 | 622: _MsgType_name[7248:7264], | ||
876 | 624: _MsgType_name[7264:7282], | ||
877 | 625: _MsgType_name[7282:7306], | ||
878 | 626: _MsgType_name[7306:7325], | ||
879 | 627: _MsgType_name[7325:7349], | ||
880 | 628: _MsgType_name[7349:7373], | ||
881 | 629: _MsgType_name[7373:7392], | ||
882 | 630: _MsgType_name[7392:7411], | ||
883 | 631: _MsgType_name[7411:7430], | ||
884 | 632: _MsgType_name[7430:7449], | ||
885 | 633: _MsgType_name[7449:7476], | ||
886 | 636: _MsgType_name[7476:7496], | ||
887 | 637: _MsgType_name[7496:7525], | ||
888 | 638: _MsgType_name[7525:7546], | ||
889 | 639: _MsgType_name[7546:7576], | ||
890 | 640: _MsgType_name[7576:7609], | ||
891 | 641: _MsgType_name[7609:7640], | ||
892 | 642: _MsgType_name[7640:7680], | ||
893 | 643: _MsgType_name[7680:7718], | ||
894 | 644: _MsgType_name[7718:7758], | ||
895 | 645: _MsgType_name[7758:7792], | ||
896 | 647: _MsgType_name[7792:7824], | ||
897 | 648: _MsgType_name[7824:7866], | ||
898 | 649: _MsgType_name[7866:7890], | ||
899 | 650: _MsgType_name[7890:7934], | ||
900 | 651: _MsgType_name[7934:7972], | ||
901 | 652: _MsgType_name[7972:8008], | ||
902 | 660: _MsgType_name[8008:8038], | ||
903 | 661: _MsgType_name[8038:8067], | ||
904 | 662: _MsgType_name[8067:8095], | ||
905 | 663: _MsgType_name[8095:8121], | ||
906 | 664: _MsgType_name[8121:8146], | ||
907 | 665: _MsgType_name[8146:8180], | ||
908 | 666: _MsgType_name[8180:8206], | ||
909 | 668: _MsgType_name[8206:8232], | ||
910 | 669: _MsgType_name[8232:8256], | ||
911 | 670: _MsgType_name[8256:8281], | ||
912 | 671: _MsgType_name[8281:8312], | ||
913 | 672: _MsgType_name[8312:8335], | ||
914 | 673: _MsgType_name[8335:8365], | ||
915 | 674: _MsgType_name[8365:8390], | ||
916 | 675: _MsgType_name[8390:8419], | ||
917 | 676: _MsgType_name[8419:8448], | ||
918 | 677: _MsgType_name[8448:8474], | ||
919 | 680: _MsgType_name[8474:8494], | ||
920 | 681: _MsgType_name[8494:8515], | ||
921 | 682: _MsgType_name[8515:8540], | ||
922 | 683: _MsgType_name[8540:8559], | ||
923 | 684: _MsgType_name[8559:8582], | ||
924 | 685: _MsgType_name[8582:8603], | ||
925 | 686: _MsgType_name[8603:8620], | ||
926 | 687: _MsgType_name[8620:8641], | ||
927 | 688: _MsgType_name[8641:8663], | ||
928 | 689: _MsgType_name[8663:8696], | ||
929 | 691: _MsgType_name[8696:8712], | ||
930 | 692: _MsgType_name[8712:8735], | ||
931 | 693: _MsgType_name[8735:8758], | ||
932 | 694: _MsgType_name[8758:8783], | ||
933 | 695: _MsgType_name[8783:8808], | ||
934 | 696: _MsgType_name[8808:8829], | ||
935 | 697: _MsgType_name[8829:8849], | ||
936 | 698: _MsgType_name[8849:8872], | ||
937 | 699: _MsgType_name[8872:8892], | ||
938 | 701: _MsgType_name[8892:8915], | ||
939 | 702: _MsgType_name[8915:8938], | ||
940 | 703: _MsgType_name[8938:8956], | ||
941 | 704: _MsgType_name[8956:8981], | ||
942 | 705: _MsgType_name[8981:9002], | ||
943 | 730: _MsgType_name[9002:9024], | ||
944 | 731: _MsgType_name[9024:9058], | ||
945 | 732: _MsgType_name[9058:9091], | ||
946 | 733: _MsgType_name[9091:9124], | ||
947 | 734: _MsgType_name[9124:9154], | ||
948 | 735: _MsgType_name[9154:9184], | ||
949 | 736: _MsgType_name[9184:9217], | ||
950 | 737: _MsgType_name[9217:9249], | ||
951 | 738: _MsgType_name[9249:9284], | ||
952 | 739: _MsgType_name[9284:9309], | ||
953 | 740: _MsgType_name[9309:9342], | ||
954 | 741: _MsgType_name[9342:9378], | ||
955 | 742: _MsgType_name[9378:9414], | ||
956 | 743: _MsgType_name[9414:9450], | ||
957 | 744: _MsgType_name[9450:9485], | ||
958 | 745: _MsgType_name[9485:9513], | ||
959 | 750: _MsgType_name[9513:9539], | ||
960 | 751: _MsgType_name[9539:9564], | ||
961 | 752: _MsgType_name[9564:9590], | ||
962 | 753: _MsgType_name[9590:9617], | ||
963 | 754: _MsgType_name[9617:9643], | ||
964 | 755: _MsgType_name[9643:9665], | ||
965 | 756: _MsgType_name[9665:9688], | ||
966 | 757: _MsgType_name[9688:9709], | ||
967 | 758: _MsgType_name[9709:9730], | ||
968 | 759: _MsgType_name[9730:9756], | ||
969 | 760: _MsgType_name[9756:9784], | ||
970 | 761: _MsgType_name[9784:9813], | ||
971 | 762: _MsgType_name[9813:9846], | ||
972 | 780: _MsgType_name[9846:9879], | ||
973 | 781: _MsgType_name[9879:9911], | ||
974 | 782: _MsgType_name[9911:9948], | ||
975 | 783: _MsgType_name[9948:9985], | ||
976 | 820: _MsgType_name[9985:10004], | ||
977 | 821: _MsgType_name[10004:10025], | ||
978 | 822: _MsgType_name[10025:10053], | ||
979 | 823: _MsgType_name[10053:10078], | ||
980 | 824: _MsgType_name[10078:10097], | ||
981 | 825: _MsgType_name[10097:10123], | ||
982 | 826: _MsgType_name[10123:10149], | ||
983 | 840: _MsgType_name[10149:10171], | ||
984 | 841: _MsgType_name[10171:10192], | ||
985 | 842: _MsgType_name[10192:10217], | ||
986 | 843: _MsgType_name[10217:10239], | ||
987 | 844: _MsgType_name[10239:10269], | ||
988 | 845: _MsgType_name[10269:10295], | ||
989 | 846: _MsgType_name[10295:10319], | ||
990 | 847: _MsgType_name[10319:10344], | ||
991 | 848: _MsgType_name[10344:10366], | ||
992 | 849: _MsgType_name[10366:10392], | ||
993 | 850: _MsgType_name[10392:10417], | ||
994 | 851: _MsgType_name[10417:10440], | ||
995 | 852: _MsgType_name[10440:10462], | ||
996 | 853: _MsgType_name[10462:10483], | ||
997 | 854: _MsgType_name[10483:10501], | ||
998 | 855: _MsgType_name[10501:10523], | ||
999 | 856: _MsgType_name[10523:10543], | ||
1000 | 857: _MsgType_name[10543:10567], | ||
1001 | 858: _MsgType_name[10567:10590], | ||
1002 | 859: _MsgType_name[10590:10615], | ||
1003 | 880: _MsgType_name[10615:10639], | ||
1004 | 881: _MsgType_name[10639:10670], | ||
1005 | 882: _MsgType_name[10670:10699], | ||
1006 | 883: _MsgType_name[10699:10732], | ||
1007 | 884: _MsgType_name[10732:10768], | ||
1008 | 885: _MsgType_name[10768:10791], | ||
1009 | 886: _MsgType_name[10791:10825], | ||
1010 | 887: _MsgType_name[10825:10852], | ||
1011 | 888: _MsgType_name[10852:10874], | ||
1012 | 890: _MsgType_name[10874:10890], | ||
1013 | 891: _MsgType_name[10890:10906], | ||
1014 | 892: _MsgType_name[10906:10948], | ||
1015 | 893: _MsgType_name[10948:10969], | ||
1016 | 894: _MsgType_name[10969:11000], | ||
1017 | 910: _MsgType_name[11000:11020], | ||
1018 | 911: _MsgType_name[11020:11049], | ||
1019 | 912: _MsgType_name[11049:11071], | ||
1020 | 913: _MsgType_name[11071:11091], | ||
1021 | 914: _MsgType_name[11091:11114], | ||
1022 | 915: _MsgType_name[11114:11126], | ||
1023 | 916: _MsgType_name[11126:11138], | ||
1024 | 917: _MsgType_name[11138:11157], | ||
1025 | 950: _MsgType_name[11157:11178], | ||
1026 | 951: _MsgType_name[11178:11193], | ||
1027 | 952: _MsgType_name[11193:11216], | ||
1028 | 953: _MsgType_name[11216:11237], | ||
1029 | 954: _MsgType_name[11237:11252], | ||
1030 | 955: _MsgType_name[11252:11273], | ||
1031 | 956: _MsgType_name[11273:11293], | ||
1032 | 957: _MsgType_name[11293:11312], | ||
1033 | 961: _MsgType_name[11312:11339], | ||
1034 | 962: _MsgType_name[11339:11367], | ||
1035 | 963: _MsgType_name[11367:11404], | ||
1036 | 964: _MsgType_name[11404:11440], | ||
1037 | 965: _MsgType_name[11440:11476], | ||
1038 | 966: _MsgType_name[11476:11504], | ||
1039 | 967: _MsgType_name[11504:11528], | ||
1040 | 968: _MsgType_name[11528:11553], | ||
1041 | 969: _MsgType_name[11553:11578], | ||
1042 | 970: _MsgType_name[11578:11610], | ||
1043 | 971: _MsgType_name[11610:11636], | ||
1044 | 972: _MsgType_name[11636:11669], | ||
1045 | 973: _MsgType_name[11669:11703], | ||
1046 | 974: _MsgType_name[11703:11736], | ||
1047 | 975: _MsgType_name[11736:11769], | ||
1048 | 976: _MsgType_name[11769:11797], | ||
1049 | 981: _MsgType_name[11797:11818], | ||
1050 | 982: _MsgType_name[11818:11846], | ||
1051 | 983: _MsgType_name[11846:11868], | ||
1052 | 984: _MsgType_name[11868:11897], | ||
1053 | 1000: _MsgType_name[11897:11924], | ||
1054 | 1001: _MsgType_name[11924:11955], | ||
1055 | 1002: _MsgType_name[11955:11982], | ||
1056 | 1003: _MsgType_name[11982:12010], | ||
1057 | 1004: _MsgType_name[12010:12057], | ||
1058 | 1005: _MsgType_name[12057:12102], | ||
1059 | 1006: _MsgType_name[12102:12133], | ||
1060 | 1007: _MsgType_name[12133:12152], | ||
1061 | 1008: _MsgType_name[12152:12178], | ||
1062 | 1009: _MsgType_name[12178:12202], | ||
1063 | 1010: _MsgType_name[12202:12228], | ||
1064 | 1011: _MsgType_name[12228:12258], | ||
1065 | 1012: _MsgType_name[12258:12285], | ||
1066 | 1013: _MsgType_name[12285:12307], | ||
1067 | 1014: _MsgType_name[12307:12332], | ||
1068 | 1015: _MsgType_name[12332:12358], | ||
1069 | 1016: _MsgType_name[12358:12396], | ||
1070 | 1020: _MsgType_name[12396:12416], | ||
1071 | 1021: _MsgType_name[12416:12435], | ||
1072 | 1022: _MsgType_name[12435:12460], | ||
1073 | 1023: _MsgType_name[12460:12486], | ||
1074 | 1024: _MsgType_name[12486:12516], | ||
1075 | 1025: _MsgType_name[12516:12547], | ||
1076 | 1030: _MsgType_name[12547:12583], | ||
1077 | 1031: _MsgType_name[12583:12611], | ||
1078 | 1032: _MsgType_name[12611:12643], | ||
1079 | 1033: _MsgType_name[12643:12677], | ||
1080 | 1034: _MsgType_name[12677:12703], | ||
1081 | 1035: _MsgType_name[12703:12733], | ||
1082 | 1036: _MsgType_name[12733:12766], | ||
1083 | 1037: _MsgType_name[12766:12791], | ||
1084 | 1038: _MsgType_name[12791:12820], | ||
1085 | 1039: _MsgType_name[12820:12856], | ||
1086 | 1040: _MsgType_name[12856:12884], | ||
1087 | 1041: _MsgType_name[12884:12916], | ||
1088 | 1059: _MsgType_name[12916:12929], | ||
1089 | 1060: _MsgType_name[12929:12945], | ||
1090 | 1061: _MsgType_name[12945:12964], | ||
1091 | 1062: _MsgType_name[12964:12999], | ||
1092 | 1063: _MsgType_name[12999:13036], | ||
1093 | 1064: _MsgType_name[13036:13058], | ||
1094 | 1065: _MsgType_name[13058:13081], | ||
1095 | 1066: _MsgType_name[13081:13105], | ||
1096 | 1110: _MsgType_name[13105:13130], | ||
1097 | 1111: _MsgType_name[13130:13153], | ||
1098 | 1112: _MsgType_name[13153:13179], | ||
1099 | 1130: _MsgType_name[13179:13208], | ||
1100 | 1131: _MsgType_name[13208:13235], | ||
1101 | 1132: _MsgType_name[13235:13263], | ||
1102 | 1133: _MsgType_name[13263:13294], | ||
1103 | 1134: _MsgType_name[13294:13323], | ||
1104 | 1135: _MsgType_name[13323:13353], | ||
1105 | 65535: _MsgType_name[13353:13360], | ||
1106 | } | ||
1107 | |||
1108 | func (i MsgType) String() string { | ||
1109 | if str, ok := _MsgType_map[i]; ok { | ||
1110 | return str | ||
1111 | } | ||
1112 | return "MsgType(" + strconv.FormatInt(int64(i), 10) + ")" | ||
1113 | } | ||
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 | |||
3 | go 1.18 | 3 | go 1.18 |
4 | 4 | ||
5 | require ( | 5 | require ( |
6 | github.com/bfix/gospel v1.2.18 | 6 | github.com/bfix/gospel v1.2.19 |
7 | github.com/go-redis/redis/v8 v8.11.5 | 7 | github.com/go-redis/redis/v8 v8.11.5 |
8 | github.com/go-sql-driver/mysql v1.6.0 | 8 | github.com/go-sql-driver/mysql v1.6.0 |
9 | github.com/gorilla/mux v1.8.0 | 9 | github.com/gorilla/mux v1.8.0 |
@@ -24,4 +24,4 @@ require ( | |||
24 | golang.org/x/tools v0.1.11 // indirect | 24 | golang.org/x/tools v0.1.11 // indirect |
25 | ) | 25 | ) |
26 | 26 | ||
27 | //replace github.com/bfix/gospel v1.2.18 => ../gospel | 27 | // 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 @@ | |||
1 | github.com/bfix/gospel v1.2.18 h1:X9hYudt5dvjYTGGmKC4T7qcLdb7ORblVD4kAC/ZYXdU= | 1 | github.com/bfix/gospel v1.2.19 h1:B57L5CMjKPeRPtVxt1JcSx42AKwD+SpN32QaF0DxXFM= |
2 | github.com/bfix/gospel v1.2.18/go.mod h1:cdu63bA9ZdfeDoqZ+vnWOcbY9Puwdzmf5DMxMGMznRI= | 2 | github.com/bfix/gospel v1.2.19/go.mod h1:cdu63bA9ZdfeDoqZ+vnWOcbY9Puwdzmf5DMxMGMznRI= |
3 | github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= | 3 | github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= |
4 | github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= | 4 | github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= |
5 | github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= | 5 | 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 | |||
20 | 20 | ||
21 | import ( | 21 | import ( |
22 | "fmt" | 22 | "fmt" |
23 | "gnunet/enums" | ||
23 | ) | 24 | ) |
24 | 25 | ||
25 | // NewEmptyMessage creates a new empty message object for the given type. | 26 | // NewEmptyMessage creates a new empty message object for the given type. |
26 | func NewEmptyMessage(msgType uint16) (Message, error) { | 27 | func NewEmptyMessage(msgType enums.MsgType) (Message, error) { |
27 | switch msgType { | 28 | switch msgType { |
28 | //------------------------------------------------------------------ | 29 | //------------------------------------------------------------------ |
29 | // Transport | 30 | // Transport |
30 | //------------------------------------------------------------------ | 31 | //------------------------------------------------------------------ |
31 | case TRANSPORT_TCP_WELCOME: | 32 | case enums.MSG_TRANSPORT_TCP_WELCOME: |
32 | return NewTransportTCPWelcomeMsg(nil), nil | 33 | return NewTransportTCPWelcomeMsg(nil), nil |
33 | case HELLO: | 34 | case enums.MSG_HELLO: |
34 | return NewHelloMsg(nil), nil | 35 | return NewHelloMsg(nil), nil |
35 | case TRANSPORT_SESSION_QUOTA: | 36 | case enums.MSG_TRANSPORT_SESSION_QUOTA: |
36 | return NewSessionQuotaMsg(0), nil | 37 | return NewSessionQuotaMsg(0), nil |
37 | case TRANSPORT_SESSION_SYN: | 38 | case enums.MSG_TRANSPORT_SESSION_SYN: |
38 | return NewSessionSynMsg(), nil | 39 | return NewSessionSynMsg(), nil |
39 | case TRANSPORT_SESSION_SYN_ACK: | 40 | case enums.MSG_TRANSPORT_SESSION_SYN_ACK: |
40 | return NewSessionSynAckMsg(), nil | 41 | return NewSessionSynAckMsg(), nil |
41 | case TRANSPORT_SESSION_ACK: | 42 | case enums.MSG_TRANSPORT_SESSION_ACK: |
42 | return new(SessionAckMsg), nil | 43 | return new(SessionAckMsg), nil |
43 | case TRANSPORT_PING: | 44 | case enums.MSG_TRANSPORT_PING: |
44 | return NewTransportPingMsg(nil, nil), nil | 45 | return NewTransportPingMsg(nil, nil), nil |
45 | case TRANSPORT_PONG: | 46 | case enums.MSG_TRANSPORT_PONG: |
46 | return NewTransportPongMsg(0, nil), nil | 47 | return NewTransportPongMsg(0, nil), nil |
47 | case TRANSPORT_SESSION_KEEPALIVE: | 48 | case enums.MSG_TRANSPORT_SESSION_KEEPALIVE: |
48 | return NewSessionKeepAliveMsg(), nil | 49 | return NewSessionKeepAliveMsg(), nil |
49 | 50 | ||
50 | //------------------------------------------------------------------ | 51 | //------------------------------------------------------------------ |
51 | // Core | 52 | // Core |
52 | //------------------------------------------------------------------ | 53 | //------------------------------------------------------------------ |
53 | case CORE_EPHEMERAL_KEY: | 54 | case enums.MSG_CORE_EPHEMERAL_KEY: |
54 | return NewEphemeralKeyMsg(), nil | 55 | return NewEphemeralKeyMsg(), nil |
55 | 56 | ||
56 | //------------------------------------------------------------------ | 57 | //------------------------------------------------------------------ |
57 | // DHT | 58 | // DHT |
58 | //------------------------------------------------------------------ | 59 | //------------------------------------------------------------------ |
59 | case DHT_CLIENT_PUT: | 60 | case enums.MSG_DHT_CLIENT_PUT: |
60 | return NewDHTClientPutMsg(nil, 0, nil), nil | 61 | return NewDHTClientPutMsg(nil, 0, nil), nil |
61 | case DHT_CLIENT_GET: | 62 | case enums.MSG_DHT_CLIENT_GET: |
62 | return NewDHTClientGetMsg(nil), nil | 63 | return NewDHTClientGetMsg(nil), nil |
63 | case DHT_CLIENT_GET_STOP: | 64 | case enums.MSG_DHT_CLIENT_GET_STOP: |
64 | return NewDHTClientGetStopMsg(nil), nil | 65 | return NewDHTClientGetStopMsg(nil), nil |
65 | case DHT_CLIENT_RESULT: | 66 | case enums.MSG_DHT_CLIENT_RESULT: |
66 | return NewDHTClientResultMsg(nil), nil | 67 | return NewDHTClientResultMsg(nil), nil |
67 | case DHT_CLIENT_GET_RESULTS_KNOWN: | 68 | case enums.MSG_DHT_CLIENT_GET_RESULTS_KNOWN: |
68 | return NewDHTClientGetResultsKnownMsg(nil), nil | 69 | return NewDHTClientGetResultsKnownMsg(nil), nil |
69 | 70 | ||
70 | //------------------------------------------------------------------ | 71 | //------------------------------------------------------------------ |
71 | // DHT-P2P | 72 | // DHT-P2P |
72 | //------------------------------------------------------------------ | 73 | //------------------------------------------------------------------ |
73 | case DHT_P2P_HELLO: | 74 | case enums.MSG_DHT_P2P_HELLO: |
74 | return NewDHTP2PHelloMsg(), nil | 75 | return NewDHTP2PHelloMsg(), nil |
75 | case DHT_P2P_GET: | 76 | case enums.MSG_DHT_P2P_GET: |
76 | return NewDHTP2PGetMsg(), nil | 77 | return NewDHTP2PGetMsg(), nil |
77 | case DHT_P2P_PUT: | 78 | case enums.MSG_DHT_P2P_PUT: |
78 | return NewDHTP2PPutMsg(), nil | 79 | return NewDHTP2PPutMsg(), nil |
79 | case DHT_P2P_RESULT: | 80 | case enums.MSG_DHT_P2P_RESULT: |
80 | return NewDHTP2PResultMsg(), nil | 81 | return NewDHTP2PResultMsg(), nil |
81 | 82 | ||
82 | //------------------------------------------------------------------ | 83 | //------------------------------------------------------------------ |
83 | // GNS | 84 | // GNS |
84 | //------------------------------------------------------------------ | 85 | //------------------------------------------------------------------ |
85 | case GNS_LOOKUP: | 86 | case enums.MSG_GNS_LOOKUP: |
86 | return NewGNSLookupMsg(), nil | 87 | return NewGNSLookupMsg(), nil |
87 | case GNS_LOOKUP_RESULT: | 88 | case enums.MSG_GNS_LOOKUP_RESULT: |
88 | return NewGNSLookupResultMsg(0), nil | 89 | return NewGNSLookupResultMsg(0), nil |
89 | 90 | ||
90 | //------------------------------------------------------------------ | 91 | //------------------------------------------------------------------ |
91 | // Namecache | 92 | // Namecache |
92 | //------------------------------------------------------------------ | 93 | //------------------------------------------------------------------ |
93 | case NAMECACHE_LOOKUP_BLOCK: | 94 | case enums.MSG_NAMECACHE_LOOKUP_BLOCK: |
94 | return NewNamecacheLookupMsg(nil), nil | 95 | return NewNamecacheLookupMsg(nil), nil |
95 | case NAMECACHE_LOOKUP_BLOCK_RESPONSE: | 96 | case enums.MSG_NAMECACHE_LOOKUP_BLOCK_RESPONSE: |
96 | return NewNamecacheLookupResultMsg(), nil | 97 | return NewNamecacheLookupResultMsg(), nil |
97 | case NAMECACHE_BLOCK_CACHE: | 98 | case enums.MSG_NAMECACHE_BLOCK_CACHE: |
98 | return NewNamecacheCacheMsg(nil), nil | 99 | return NewNamecacheCacheMsg(nil), nil |
99 | case NAMECACHE_BLOCK_CACHE_RESPONSE: | 100 | case enums.MSG_NAMECACHE_BLOCK_CACHE_RESPONSE: |
100 | return NewNamecacheCacheResponseMsg(), nil | 101 | return NewNamecacheCacheResponseMsg(), nil |
101 | 102 | ||
102 | //------------------------------------------------------------------ | 103 | //------------------------------------------------------------------ |
103 | // Revocation | 104 | // Revocation |
104 | //------------------------------------------------------------------ | 105 | //------------------------------------------------------------------ |
105 | case REVOCATION_QUERY: | 106 | case enums.MSG_REVOCATION_QUERY: |
106 | return NewRevocationQueryMsg(nil), nil | 107 | return NewRevocationQueryMsg(nil), nil |
107 | case REVOCATION_QUERY_RESPONSE: | 108 | case enums.MSG_REVOCATION_QUERY_RESPONSE: |
108 | return NewRevocationQueryResponseMsg(true), nil | 109 | return NewRevocationQueryResponseMsg(true), nil |
109 | case REVOCATION_REVOKE: | 110 | case enums.MSG_REVOCATION_REVOKE: |
110 | return NewRevocationRevokeMsg(nil), nil | 111 | return NewRevocationRevokeMsg(nil), nil |
111 | case REVOCATION_REVOKE_RESPONSE: | 112 | case enums.MSG_REVOCATION_REVOKE_RESPONSE: |
112 | return NewRevocationRevokeResponseMsg(false), nil | 113 | return NewRevocationRevokeResponseMsg(false), nil |
113 | } | 114 | } |
114 | return nil, fmt.Errorf("unknown message type %d", msgType) | 115 | 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 | |||
20 | 20 | ||
21 | import ( | 21 | import ( |
22 | "errors" | 22 | "errors" |
23 | "gnunet/enums" | ||
23 | 24 | ||
24 | "github.com/bfix/gospel/data" | 25 | "github.com/bfix/gospel/data" |
25 | ) | 26 | ) |
@@ -33,8 +34,12 @@ var ( | |||
33 | 34 | ||
34 | // Message is an interface for all GNUnet-specific messages. | 35 | // Message is an interface for all GNUnet-specific messages. |
35 | type Message interface { | 36 | type Message interface { |
36 | // Header of message | 37 | |
37 | Header() *Header | 38 | // Size returns the size of the full message |
39 | Size() uint16 | ||
40 | |||
41 | // Type returns the message type (defines the layout of the body data) | ||
42 | Type() enums.MsgType | ||
38 | 43 | ||
39 | // String returns a human-readable message | 44 | // String returns a human-readable message |
40 | String() string | 45 | String() string |
@@ -42,30 +47,30 @@ type Message interface { | |||
42 | 47 | ||
43 | //---------------------------------------------------------------------- | 48 | //---------------------------------------------------------------------- |
44 | 49 | ||
45 | // Header encapsulates the common part of all GNUnet messages (at the | 50 | // MsgHeader encapsulates the common part of all GNUnet messages (at the |
46 | // beginning of the data). | 51 | // beginning of the data). |
47 | type Header struct { | 52 | type MsgHeader struct { |
48 | MsgSize uint16 `order:"big"` | 53 | MsgSize uint16 `order:"big"` |
49 | MsgType uint16 `order:"big"` | 54 | MsgType enums.MsgType `order:"big"` |
50 | } | 55 | } |
51 | 56 | ||
52 | // Size returns the total size of the message (header + body) | 57 | // Size returns the total size of the message (header + body) |
53 | func (mh *Header) Size() uint16 { | 58 | func (mh *MsgHeader) Size() uint16 { |
54 | return mh.MsgSize | 59 | return mh.MsgSize |
55 | } | 60 | } |
56 | 61 | ||
57 | // Type returns the message type (defines the layout of the body data) | 62 | // Type returns the message type (defines the layout of the body data) |
58 | func (mh *Header) Type() uint16 { | 63 | func (mh *MsgHeader) Type() enums.MsgType { |
59 | return mh.MsgType | 64 | return mh.MsgType |
60 | } | 65 | } |
61 | 66 | ||
62 | // GetMsgHeader returns the header of a message from a byte array (as the | 67 | // GetMsgHeader returns the header of a message from a byte array (as the |
63 | // serialized form). | 68 | // serialized form). |
64 | func GetMsgHeader(b []byte) (mh *Header, err error) { | 69 | func GetMsgHeader(b []byte) (mh *MsgHeader, err error) { |
65 | if b == nil || len(b) < 4 { | 70 | if b == nil || len(b) < 4 { |
66 | return nil, ErrMsgHeaderTooSmall | 71 | return nil, ErrMsgHeaderTooSmall |
67 | } | 72 | } |
68 | mh = new(Header) | 73 | mh = new(MsgHeader) |
69 | err = data.Unmarshal(mh, b) | 74 | err = data.Unmarshal(mh, b) |
70 | return | 75 | return |
71 | } | 76 | } |
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 { | |||
43 | // EphemeralKeyMsg announces a new transient key for a peer. The key is signed | 43 | // EphemeralKeyMsg announces a new transient key for a peer. The key is signed |
44 | // by the issuing peer. | 44 | // by the issuing peer. |
45 | type EphemeralKeyMsg struct { | 45 | type EphemeralKeyMsg struct { |
46 | MsgSize uint16 `order:"big"` // total size of message | 46 | MsgHeader |
47 | MsgType uint16 `order:"big"` // CORE_EPHEMERAL_KEY (88) | ||
48 | SenderStatus uint32 `order:"big"` // enum PeerStateMachine | 47 | SenderStatus uint32 `order:"big"` // enum PeerStateMachine |
49 | Signature *util.PeerSignature `` // EdDSA signature | 48 | Signature *util.PeerSignature `` // EdDSA signature |
50 | SignedBlock *EphKeyBlock | 49 | SignedBlock *EphKeyBlock |
@@ -53,8 +52,7 @@ type EphemeralKeyMsg struct { | |||
53 | // NewEphemeralKeyMsg creates an empty message for key announcement. | 52 | // NewEphemeralKeyMsg creates an empty message for key announcement. |
54 | func NewEphemeralKeyMsg() *EphemeralKeyMsg { | 53 | func NewEphemeralKeyMsg() *EphemeralKeyMsg { |
55 | return &EphemeralKeyMsg{ | 54 | return &EphemeralKeyMsg{ |
56 | MsgSize: 160, | 55 | MsgHeader: MsgHeader{160, enums.MSG_CORE_EPHEMERAL_KEY}, |
57 | MsgType: CORE_EPHEMERAL_KEY, | ||
58 | SenderStatus: 1, | 56 | SenderStatus: 1, |
59 | Signature: util.NewPeerSignature(nil), | 57 | Signature: util.NewPeerSignature(nil), |
60 | SignedBlock: &EphKeyBlock{ | 58 | SignedBlock: &EphKeyBlock{ |
@@ -79,11 +77,6 @@ func (m *EphemeralKeyMsg) String() string { | |||
79 | m.SenderStatus) | 77 | m.SenderStatus) |
80 | } | 78 | } |
81 | 79 | ||
82 | // Header returns the message header in a separate instance. | ||
83 | func (m *EphemeralKeyMsg) Header() *Header { | ||
84 | return &Header{m.MsgSize, m.MsgType} | ||
85 | } | ||
86 | |||
87 | // Public extracts the public key of an announcing peer. | 80 | // Public extracts the public key of an announcing peer. |
88 | func (m *EphemeralKeyMsg) Public() *util.PeerPublicKey { | 81 | func (m *EphemeralKeyMsg) Public() *util.PeerPublicKey { |
89 | return util.NewPeerPublicKey(m.SignedBlock.PeerID.Data) | 82 | 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 @@ | |||
19 | package message | 19 | package message |
20 | 20 | ||
21 | import ( | 21 | import ( |
22 | "encoding/hex" | ||
23 | "fmt" | 22 | "fmt" |
24 | 23 | ||
25 | "gnunet/crypto" | 24 | "gnunet/crypto" |
@@ -33,9 +32,8 @@ import ( | |||
33 | 32 | ||
34 | // DHTClientPutMsg is the message for putting values into the DHT | 33 | // DHTClientPutMsg is the message for putting values into the DHT |
35 | type DHTClientPutMsg struct { | 34 | type DHTClientPutMsg struct { |
36 | MsgSize uint16 `order:"big"` // total size of message | 35 | MsgHeader |
37 | MsgType uint16 `order:"big"` // DHT_CLIENT_PUT (142) | 36 | BType enums.BlockType `order:"big"` // The type of the data (BLOCK_TYPE_???) |
38 | Type uint32 `order:"big"` // The type of the data (BLOCK_TYPE_???) | ||
39 | Options uint32 `order:"big"` // Message options (DHT_RO_???) | 37 | Options uint32 `order:"big"` // Message options (DHT_RO_???) |
40 | ReplLevel uint32 `order:"big"` // Replication level for this message | 38 | ReplLevel uint32 `order:"big"` // Replication level for this message |
41 | Expire util.AbsoluteTime // Expiration time | 39 | Expire util.AbsoluteTime // Expiration time |
@@ -44,7 +42,7 @@ type DHTClientPutMsg struct { | |||
44 | } | 42 | } |
45 | 43 | ||
46 | // NewDHTClientPutMsg creates a new default DHTClientPutMsg object. | 44 | // NewDHTClientPutMsg creates a new default DHTClientPutMsg object. |
47 | func NewDHTClientPutMsg(key *crypto.HashCode, btype int, data []byte) *DHTClientPutMsg { | 45 | func NewDHTClientPutMsg(key *crypto.HashCode, btype enums.BlockType, data []byte) *DHTClientPutMsg { |
48 | if key == nil { | 46 | if key == nil { |
49 | key = new(crypto.HashCode) | 47 | key = new(crypto.HashCode) |
50 | } | 48 | } |
@@ -53,9 +51,8 @@ func NewDHTClientPutMsg(key *crypto.HashCode, btype int, data []byte) *DHTClient | |||
53 | size += uint16(len(data)) | 51 | size += uint16(len(data)) |
54 | } | 52 | } |
55 | return &DHTClientPutMsg{ | 53 | return &DHTClientPutMsg{ |
56 | MsgSize: size, | 54 | MsgHeader: MsgHeader{size, enums.MSG_DHT_CLIENT_PUT}, |
57 | MsgType: DHT_CLIENT_PUT, | 55 | BType: btype, |
58 | Type: uint32(btype), | ||
59 | Options: uint32(enums.DHT_RO_NONE), | 56 | Options: uint32(enums.DHT_RO_NONE), |
60 | ReplLevel: 1, | 57 | ReplLevel: 1, |
61 | Expire: util.AbsoluteTimeNever(), | 58 | Expire: util.AbsoluteTimeNever(), |
@@ -66,13 +63,8 @@ func NewDHTClientPutMsg(key *crypto.HashCode, btype int, data []byte) *DHTClient | |||
66 | 63 | ||
67 | // String returns a human-readable representation of the message. | 64 | // String returns a human-readable representation of the message. |
68 | func (m *DHTClientPutMsg) String() string { | 65 | func (m *DHTClientPutMsg) String() string { |
69 | return fmt.Sprintf("DHTClientPutMsg{Type=%d,Expire=%s,Options=%d,Repl=%d,Key=%s}", | 66 | return fmt.Sprintf("DHTClientPutMsg{Type=%s,Expire=%s,Options=%d,Repl=%d,Key=%s}", |
70 | m.Type, m.Expire, m.Options, m.ReplLevel, hex.EncodeToString(m.Key.Bits)) | 67 | m.BType, m.Expire, m.Options, m.ReplLevel, m.Key) |
71 | } | ||
72 | |||
73 | // Header returns the message header in a separate instance. | ||
74 | func (m *DHTClientPutMsg) Header() *Header { | ||
75 | return &Header{m.MsgSize, m.MsgType} | ||
76 | } | 68 | } |
77 | 69 | ||
78 | //---------------------------------------------------------------------- | 70 | //---------------------------------------------------------------------- |
@@ -81,11 +73,10 @@ func (m *DHTClientPutMsg) Header() *Header { | |||
81 | 73 | ||
82 | // DHTClientGetMsg is the message for getting values from the DHT | 74 | // DHTClientGetMsg is the message for getting values from the DHT |
83 | type DHTClientGetMsg struct { | 75 | type DHTClientGetMsg struct { |
84 | MsgSize uint16 `order:"big"` // total size of message | 76 | MsgHeader |
85 | MsgType uint16 `order:"big"` // DHT_CLIENT_GET (143) | ||
86 | Options uint32 `order:"big"` // Message options (DHT_RO_???) | 77 | Options uint32 `order:"big"` // Message options (DHT_RO_???) |
87 | ReplLevel uint32 `order:"big"` // Replication level for this message | 78 | ReplLevel uint32 `order:"big"` // Replication level for this message |
88 | Type uint32 `order:"big"` // The type for the data for the GET request (BLOCK_TYPE_???) | 79 | BType enums.BlockType `order:"big"` // The type for the data for the GET request (BLOCK_TYPE_???) |
89 | Key *crypto.HashCode // The key to search for | 80 | Key *crypto.HashCode // The key to search for |
90 | ID uint64 `order:"big"` // Unique ID identifying this request | 81 | ID uint64 `order:"big"` // Unique ID identifying this request |
91 | XQuery []byte `size:"*"` // Optional xquery | 82 | XQuery []byte `size:"*"` // Optional xquery |
@@ -97,11 +88,10 @@ func NewDHTClientGetMsg(key *crypto.HashCode) *DHTClientGetMsg { | |||
97 | key = new(crypto.HashCode) | 88 | key = new(crypto.HashCode) |
98 | } | 89 | } |
99 | return &DHTClientGetMsg{ | 90 | return &DHTClientGetMsg{ |
100 | MsgSize: 88, | 91 | MsgHeader: MsgHeader{88, enums.MSG_DHT_CLIENT_GET}, |
101 | MsgType: DHT_CLIENT_GET, | ||
102 | Options: uint32(enums.DHT_RO_NONE), | 92 | Options: uint32(enums.DHT_RO_NONE), |
103 | ReplLevel: 1, | 93 | ReplLevel: 1, |
104 | Type: uint32(enums.BLOCK_TYPE_ANY), | 94 | BType: enums.BLOCK_TYPE_ANY, |
105 | Key: key, | 95 | Key: key, |
106 | ID: 0, | 96 | ID: 0, |
107 | XQuery: nil, | 97 | XQuery: nil, |
@@ -119,13 +109,8 @@ func (m *DHTClientGetMsg) SetXQuery(xq []byte) []byte { | |||
119 | 109 | ||
120 | // String returns a human-readable representation of the message. | 110 | // String returns a human-readable representation of the message. |
121 | func (m *DHTClientGetMsg) String() string { | 111 | func (m *DHTClientGetMsg) String() string { |
122 | return fmt.Sprintf("DHTClientGetMsg{Id:%d,Type=%d,Options=%d,Repl=%d,Key=%s}", | 112 | return fmt.Sprintf("DHTClientGetMsg{Id:%d,Type=%s,Options=%d,Repl=%d,Key=%s}", |
123 | m.ID, m.Type, m.Options, m.ReplLevel, hex.EncodeToString(m.Key.Bits)) | 113 | m.ID, m.BType, m.Options, m.ReplLevel, m.Key) |
124 | } | ||
125 | |||
126 | // Header returns the message header in a separate instance. | ||
127 | func (m *DHTClientGetMsg) Header() *Header { | ||
128 | return &Header{m.MsgSize, m.MsgType} | ||
129 | } | 114 | } |
130 | 115 | ||
131 | //---------------------------------------------------------------------- | 116 | //---------------------------------------------------------------------- |
@@ -134,9 +119,8 @@ func (m *DHTClientGetMsg) Header() *Header { | |||
134 | 119 | ||
135 | // DHTClientResultMsg is a message for DHT results | 120 | // DHTClientResultMsg is a message for DHT results |
136 | type DHTClientResultMsg struct { | 121 | type DHTClientResultMsg struct { |
137 | MsgSize uint16 `order:"big"` // total size of message | 122 | MsgHeader |
138 | MsgType uint16 `order:"big"` // DHT_CLIENT_RESULT (145) | 123 | BType enums.BlockType `order:"big"` // The type for the data |
139 | Type uint32 `order:"big"` // The type for the data | ||
140 | PutPathLen uint32 `order:"big"` // Number of peers recorded in outgoing path | 124 | PutPathLen uint32 `order:"big"` // Number of peers recorded in outgoing path |
141 | GetPathLen uint32 `order:"big"` // Number of peers recorded from storage location | 125 | GetPathLen uint32 `order:"big"` // Number of peers recorded from storage location |
142 | ID uint64 `order:"big"` // Unique ID of the matching GET request | 126 | ID uint64 `order:"big"` // Unique ID of the matching GET request |
@@ -153,9 +137,8 @@ func NewDHTClientResultMsg(key *crypto.HashCode) *DHTClientResultMsg { | |||
153 | key = crypto.NewHashCode(nil) | 137 | key = crypto.NewHashCode(nil) |
154 | } | 138 | } |
155 | return &DHTClientResultMsg{ | 139 | return &DHTClientResultMsg{ |
156 | MsgSize: 64, // empty message size (no data) | 140 | MsgHeader: MsgHeader{64, enums.MSG_DHT_CLIENT_RESULT}, |
157 | MsgType: DHT_CLIENT_RESULT, | 141 | BType: 0, |
158 | Type: 0, | ||
159 | PutPathLen: 0, | 142 | PutPathLen: 0, |
160 | GetPathLen: 0, | 143 | GetPathLen: 0, |
161 | ID: 0, | 144 | ID: 0, |
@@ -167,12 +150,7 @@ func NewDHTClientResultMsg(key *crypto.HashCode) *DHTClientResultMsg { | |||
167 | 150 | ||
168 | // String returns a human-readable representation of the message. | 151 | // String returns a human-readable representation of the message. |
169 | func (m *DHTClientResultMsg) String() string { | 152 | func (m *DHTClientResultMsg) String() string { |
170 | return fmt.Sprintf("DHTClientResultMsg{id:%d,expire=%s}", m.ID, m.Expire) | 153 | return fmt.Sprintf("DHTClientResultMsg{id:%d,type=%s,expire=%s}", m.ID, m.BType, m.Expire) |
171 | } | ||
172 | |||
173 | // Header returns the message header in a separate instance. | ||
174 | func (m *DHTClientResultMsg) Header() *Header { | ||
175 | return &Header{m.MsgSize, m.MsgType} | ||
176 | } | 154 | } |
177 | 155 | ||
178 | //---------------------------------------------------------------------- | 156 | //---------------------------------------------------------------------- |
@@ -181,8 +159,7 @@ func (m *DHTClientResultMsg) Header() *Header { | |||
181 | 159 | ||
182 | // DHTClientGetStopMsg stops a pending DHT operation | 160 | // DHTClientGetStopMsg stops a pending DHT operation |
183 | type DHTClientGetStopMsg struct { | 161 | type DHTClientGetStopMsg struct { |
184 | MsgSize uint16 `order:"big"` // total size of message | 162 | MsgHeader |
185 | MsgType uint16 `order:"big"` // DHT_CLIENT_GET_STOP (144) | ||
186 | Reserved uint32 `order:"big"` // Reserved (0) | 163 | Reserved uint32 `order:"big"` // Reserved (0) |
187 | ID uint64 `order:"big"` // Unique ID identifying this request | 164 | ID uint64 `order:"big"` // Unique ID identifying this request |
188 | Key *crypto.HashCode // The key to search for | 165 | Key *crypto.HashCode // The key to search for |
@@ -194,22 +171,16 @@ func NewDHTClientGetStopMsg(key *crypto.HashCode) *DHTClientGetStopMsg { | |||
194 | key = new(crypto.HashCode) | 171 | key = new(crypto.HashCode) |
195 | } | 172 | } |
196 | return &DHTClientGetStopMsg{ | 173 | return &DHTClientGetStopMsg{ |
197 | MsgSize: 80, | 174 | MsgHeader: MsgHeader{80, enums.MSG_DHT_CLIENT_GET_STOP}, |
198 | MsgType: DHT_CLIENT_GET_STOP, | 175 | Reserved: 0, // mandatory |
199 | Reserved: 0, // mandatory | 176 | ID: 0, |
200 | ID: 0, | 177 | Key: key, |
201 | Key: key, | ||
202 | } | 178 | } |
203 | } | 179 | } |
204 | 180 | ||
205 | // String returns a human-readable representation of the message. | 181 | // String returns a human-readable representation of the message. |
206 | func (m *DHTClientGetStopMsg) String() string { | 182 | func (m *DHTClientGetStopMsg) String() string { |
207 | return fmt.Sprintf("DHTClientGetStopMsg{Id:%d,Key=%s}", m.ID, hex.EncodeToString(m.Key.Bits)) | 183 | return fmt.Sprintf("DHTClientGetStopMsg{Id:%d,Key=%s}", m.ID, m.Key) |
208 | } | ||
209 | |||
210 | // Header returns the message header in a separate instance. | ||
211 | func (m *DHTClientGetStopMsg) Header() *Header { | ||
212 | return &Header{m.MsgSize, m.MsgType} | ||
213 | } | 184 | } |
214 | 185 | ||
215 | //---------------------------------------------------------------------- | 186 | //---------------------------------------------------------------------- |
@@ -218,8 +189,7 @@ func (m *DHTClientGetStopMsg) Header() *Header { | |||
218 | 189 | ||
219 | // DHTClientGetResultsKnownMsg is the message for putting values into the DHT | 190 | // DHTClientGetResultsKnownMsg is the message for putting values into the DHT |
220 | type DHTClientGetResultsKnownMsg struct { | 191 | type DHTClientGetResultsKnownMsg struct { |
221 | MsgSize uint16 `order:"big"` // total size of message | 192 | MsgHeader |
222 | MsgType uint16 `order:"big"` // DHT_CLIENT_GET_RESULTS_KNOWN (156) | ||
223 | Reserved uint32 `order:"big"` // Reserved for further use | 193 | Reserved uint32 `order:"big"` // Reserved for further use |
224 | Key *crypto.HashCode // The key to search for | 194 | Key *crypto.HashCode // The key to search for |
225 | ID uint64 `order:"big"` // Unique ID identifying this request | 195 | ID uint64 `order:"big"` // Unique ID identifying this request |
@@ -232,11 +202,10 @@ func NewDHTClientGetResultsKnownMsg(key *crypto.HashCode) *DHTClientGetResultsKn | |||
232 | key = new(crypto.HashCode) | 202 | key = new(crypto.HashCode) |
233 | } | 203 | } |
234 | return &DHTClientGetResultsKnownMsg{ | 204 | return &DHTClientGetResultsKnownMsg{ |
235 | MsgSize: 80, | 205 | MsgHeader: MsgHeader{80, enums.MSG_DHT_CLIENT_GET_RESULTS_KNOWN}, |
236 | MsgType: DHT_CLIENT_GET_RESULTS_KNOWN, | 206 | Key: key, |
237 | Key: key, | 207 | ID: 0, |
238 | ID: 0, | 208 | Known: make([]*crypto.HashCode, 0), |
239 | Known: make([]*crypto.HashCode, 0), | ||
240 | } | 209 | } |
241 | } | 210 | } |
242 | 211 | ||
@@ -249,10 +218,5 @@ func (m *DHTClientGetResultsKnownMsg) AddKnown(hc *crypto.HashCode) { | |||
249 | // String returns a human-readable representation of the message. | 218 | // String returns a human-readable representation of the message. |
250 | func (m *DHTClientGetResultsKnownMsg) String() string { | 219 | func (m *DHTClientGetResultsKnownMsg) String() string { |
251 | return fmt.Sprintf("DHTClientGetResultsKnownMsg{Id:%d,Key=%s,Num=%d}", | 220 | return fmt.Sprintf("DHTClientGetResultsKnownMsg{Id:%d,Key=%s,Num=%d}", |
252 | m.ID, hex.EncodeToString(m.Key.Bits), len(m.Known)) | 221 | m.ID, m.Key.Data, len(m.Known)) |
253 | } | ||
254 | |||
255 | // Header returns the message header in a separate instance. | ||
256 | func (m *DHTClientGetResultsKnownMsg) Header() *Header { | ||
257 | return &Header{m.MsgSize, m.MsgType} | ||
258 | } | 222 | } |
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 ( | |||
29 | "gnunet/service/dht/blocks" | 29 | "gnunet/service/dht/blocks" |
30 | "gnunet/service/dht/path" | 30 | "gnunet/service/dht/path" |
31 | "gnunet/util" | 31 | "gnunet/util" |
32 | "strings" | ||
32 | "time" | 33 | "time" |
33 | 34 | ||
34 | "github.com/bfix/gospel/crypto/ed25519" | 35 | "github.com/bfix/gospel/crypto/ed25519" |
@@ -46,9 +47,8 @@ import ( | |||
46 | 47 | ||
47 | // DHTP2PGetMsg wire layout | 48 | // DHTP2PGetMsg wire layout |
48 | type DHTP2PGetMsg struct { | 49 | type DHTP2PGetMsg struct { |
49 | MsgSize uint16 `order:"big"` // total size of message | 50 | MsgHeader |
50 | MsgType uint16 `order:"big"` // DHT_P2P_GET (147) | 51 | BType enums.BlockType `order:"big"` // content type of the payload |
51 | BType uint32 `order:"big"` // content type of the payload | ||
52 | Flags uint16 `order:"big"` // processing flags | 52 | Flags uint16 `order:"big"` // processing flags |
53 | HopCount uint16 `order:"big"` // number of hops so far | 53 | HopCount uint16 `order:"big"` // number of hops so far |
54 | ReplLevel uint16 `order:"big"` // Replication level | 54 | ReplLevel uint16 `order:"big"` // Replication level |
@@ -62,9 +62,8 @@ type DHTP2PGetMsg struct { | |||
62 | // NewDHTP2PGetMsg creates an empty DHT-P2P-Get message | 62 | // NewDHTP2PGetMsg creates an empty DHT-P2P-Get message |
63 | func NewDHTP2PGetMsg() *DHTP2PGetMsg { | 63 | func NewDHTP2PGetMsg() *DHTP2PGetMsg { |
64 | return &DHTP2PGetMsg{ | 64 | return &DHTP2PGetMsg{ |
65 | MsgSize: 208, // message size without ResFiter and XQuery | 65 | MsgHeader: MsgHeader{208, enums.MSG_DHT_P2P_GET}, |
66 | MsgType: DHT_P2P_GET, // DHT_P2P_GET (147) | 66 | BType: enums.BLOCK_TYPE_ANY, // no block type defined |
67 | BType: 0, // no block type defined | ||
68 | Flags: 0, // no flags defined | 67 | Flags: 0, // no flags defined |
69 | HopCount: 0, // no hops | 68 | HopCount: 0, // no hops |
70 | ReplLevel: 0, // no replication level defined | 69 | ReplLevel: 0, // no replication level defined |
@@ -78,13 +77,8 @@ func NewDHTP2PGetMsg() *DHTP2PGetMsg { | |||
78 | 77 | ||
79 | // String returns a human-readable representation of the message. | 78 | // String returns a human-readable representation of the message. |
80 | func (m *DHTP2PGetMsg) String() string { | 79 | func (m *DHTP2PGetMsg) String() string { |
81 | return fmt.Sprintf("DHTP2PGetMsg{btype=%s,hops=%d,flags=%d}", | 80 | return fmt.Sprintf("DHTP2PGetMsg{btype=%s,hops=%d,flags=%s}", |
82 | enums.BlockType(m.BType).String(), m.HopCount, m.Flags) | 81 | m.BType, m.HopCount, DHTFlags(m.Flags)) |
83 | } | ||
84 | |||
85 | // Header returns the message header in a separate instance. | ||
86 | func (m *DHTP2PGetMsg) Header() *Header { | ||
87 | return &Header{m.MsgSize, m.MsgType} | ||
88 | } | 82 | } |
89 | 83 | ||
90 | // Update message (forwarding) | 84 | // Update message (forwarding) |
@@ -92,8 +86,7 @@ func (m *DHTP2PGetMsg) Update(pf *blocks.PeerFilter, rf blocks.ResultFilter, hop | |||
92 | buf := rf.Bytes() | 86 | buf := rf.Bytes() |
93 | ns := uint16(len(buf)) | 87 | ns := uint16(len(buf)) |
94 | return &DHTP2PGetMsg{ | 88 | return &DHTP2PGetMsg{ |
95 | MsgSize: m.MsgSize - m.RfSize + ns, | 89 | MsgHeader: MsgHeader{m.MsgSize - m.RfSize + ns, enums.MSG_DHT_P2P_GET}, |
96 | MsgType: DHT_P2P_GET, | ||
97 | BType: m.BType, | 90 | BType: m.BType, |
98 | Flags: m.Flags, | 91 | Flags: m.Flags, |
99 | HopCount: hop, | 92 | HopCount: hop, |
@@ -113,14 +106,13 @@ func (m *DHTP2PGetMsg) Update(pf *blocks.PeerFilter, rf blocks.ResultFilter, hop | |||
113 | 106 | ||
114 | // DHTP2PPutMsg wire layout | 107 | // DHTP2PPutMsg wire layout |
115 | type DHTP2PPutMsg struct { | 108 | type DHTP2PPutMsg struct { |
116 | MsgSize uint16 `order:"big"` // total size of message | 109 | MsgHeader |
117 | MsgType uint16 `order:"big"` // DHT_P2P_PUT (146) | 110 | BType enums.BlockType `order:"big"` // block type |
118 | BType uint32 `order:"big"` // block type | ||
119 | Flags uint16 `order:"big"` // processing flags | 111 | Flags uint16 `order:"big"` // processing flags |
120 | HopCount uint16 `order:"big"` // message hops | 112 | HopCount uint16 `order:"big"` // message hops |
121 | ReplLvl uint16 `order:"big"` // replication level | 113 | ReplLvl uint16 `order:"big"` // replication level |
122 | PathL uint16 `order:"big"` // path length | 114 | PathL uint16 `order:"big"` // path length |
123 | Expiration util.AbsoluteTime `` // expiration date | 115 | Expire util.AbsoluteTime `` // expiration date |
124 | PeerFilter *blocks.PeerFilter `` // peer bloomfilter | 116 | PeerFilter *blocks.PeerFilter `` // peer bloomfilter |
125 | Key *crypto.HashCode `` // query key to block | 117 | Key *crypto.HashCode `` // query key to block |
126 | TruncOrigin *util.PeerID `opt:"(IsUsed)"` // truncated origin (if TRUNCATED flag set) | 118 | TruncOrigin *util.PeerID `opt:"(IsUsed)"` // truncated origin (if TRUNCATED flag set) |
@@ -132,14 +124,13 @@ type DHTP2PPutMsg struct { | |||
132 | // NewDHTP2PPutMsg creates an empty new DHTP2PPutMsg | 124 | // NewDHTP2PPutMsg creates an empty new DHTP2PPutMsg |
133 | func NewDHTP2PPutMsg() *DHTP2PPutMsg { | 125 | func NewDHTP2PPutMsg() *DHTP2PPutMsg { |
134 | return &DHTP2PPutMsg{ | 126 | return &DHTP2PPutMsg{ |
135 | MsgSize: 218, // total size without path and block data | 127 | MsgHeader: MsgHeader{218, enums.MSG_DHT_P2P_PUT}, |
136 | MsgType: DHT_P2P_PUT, // DHT_P2P_PUT (146) | 128 | BType: enums.BLOCK_TYPE_ANY, // block type |
137 | BType: 0, // block type | ||
138 | Flags: 0, // processing flags | 129 | Flags: 0, // processing flags |
139 | HopCount: 0, // message hops | 130 | HopCount: 0, // message hops |
140 | ReplLvl: 0, // replication level | 131 | ReplLvl: 0, // replication level |
141 | PathL: 0, // no PUT path | 132 | PathL: 0, // no PUT path |
142 | Expiration: util.AbsoluteTimeNever(), // expiration date | 133 | Expire: util.AbsoluteTimeNever(), // expiration date |
143 | PeerFilter: blocks.NewPeerFilter(), // peer bloom filter | 134 | PeerFilter: blocks.NewPeerFilter(), // peer bloom filter |
144 | Key: crypto.NewHashCode(nil), // query key | 135 | Key: crypto.NewHashCode(nil), // query key |
145 | TruncOrigin: nil, // no truncated path | 136 | TruncOrigin: nil, // no truncated path |
@@ -168,7 +159,7 @@ func (m *DHTP2PPutMsg) Update(p *path.Path, pf *blocks.PeerFilter, hop uint16) * | |||
168 | msg.Flags = m.Flags | 159 | msg.Flags = m.Flags |
169 | msg.HopCount = hop | 160 | msg.HopCount = hop |
170 | msg.PathL = p.NumList | 161 | msg.PathL = p.NumList |
171 | msg.Expiration = m.Expiration | 162 | msg.Expire = m.Expire |
172 | msg.PeerFilter = pf | 163 | msg.PeerFilter = pf |
173 | msg.Key = m.Key.Clone() | 164 | msg.Key = m.Key.Clone() |
174 | msg.TruncOrigin = p.TruncOrigin | 165 | msg.TruncOrigin = p.TruncOrigin |
@@ -186,7 +177,7 @@ func (m *DHTP2PPutMsg) Update(p *path.Path, pf *blocks.PeerFilter, hop uint16) * | |||
186 | // Path returns the current path from message | 177 | // Path returns the current path from message |
187 | func (m *DHTP2PPutMsg) Path(sender *util.PeerID) *path.Path { | 178 | func (m *DHTP2PPutMsg) Path(sender *util.PeerID) *path.Path { |
188 | // create a "real" path list from message data | 179 | // create a "real" path list from message data |
189 | pth := path.NewPath(crypto.Hash(m.Block), m.Expiration) | 180 | pth := path.NewPath(crypto.Hash(m.Block), m.Expire) |
190 | 181 | ||
191 | // return empty path if recording is switched off | 182 | // return empty path if recording is switched off |
192 | if m.Flags&enums.DHT_RO_RECORD_ROUTE == 0 { | 183 | if m.Flags&enums.DHT_RO_RECORD_ROUTE == 0 { |
@@ -211,7 +202,7 @@ func (m *DHTP2PPutMsg) Path(sender *util.PeerID) *path.Path { | |||
211 | // handle last hop signature | 202 | // handle last hop signature |
212 | if m.LastSig == nil { | 203 | if m.LastSig == nil { |
213 | logger.Printf(logger.WARN, "[path] - last hop signature missing - path reset") | 204 | logger.Printf(logger.WARN, "[path] - last hop signature missing - path reset") |
214 | return path.NewPath(crypto.Hash(m.Block), m.Expiration) | 205 | return path.NewPath(crypto.Hash(m.Block), m.Expire) |
215 | } | 206 | } |
216 | pth.Flags |= path.PathLastHop | 207 | pth.Flags |= path.PathLastHop |
217 | pth.LastSig = m.LastSig | 208 | pth.LastSig = m.LastSig |
@@ -269,13 +260,8 @@ func (m *DHTP2PPutMsg) SetPath(p *path.Path) { | |||
269 | 260 | ||
270 | // String returns a human-readable representation of the message. | 261 | // String returns a human-readable representation of the message. |
271 | func (m *DHTP2PPutMsg) String() string { | 262 | func (m *DHTP2PPutMsg) String() string { |
272 | return fmt.Sprintf("DHTP2PPutMsg{btype=%s,hops=%d,flags=%d}", | 263 | return fmt.Sprintf("DHTP2PPutMsg{btype=%s,hops=%d,flags=%s}", |
273 | enums.BlockType(m.BType).String(), m.HopCount, m.Flags) | 264 | m.BType, m.HopCount, DHTFlags(m.Flags)) |
274 | } | ||
275 | |||
276 | // Header returns the message header in a separate instance. | ||
277 | func (m *DHTP2PPutMsg) Header() *Header { | ||
278 | return &Header{m.MsgSize, m.MsgType} | ||
279 | } | 265 | } |
280 | 266 | ||
281 | //---------------------------------------------------------------------- | 267 | //---------------------------------------------------------------------- |
@@ -285,32 +271,31 @@ func (m *DHTP2PPutMsg) Header() *Header { | |||
285 | 271 | ||
286 | // DHTP2PResultMsg wire layout | 272 | // DHTP2PResultMsg wire layout |
287 | type DHTP2PResultMsg struct { | 273 | type DHTP2PResultMsg struct { |
288 | MsgSize uint16 `order:"big"` // total size of message | 274 | MsgHeader |
289 | MsgType uint16 `order:"big"` // DHT_P2P_RESULT (148) | 275 | BType enums.BlockType `order:"big"` // Block type of result |
290 | BType uint32 `order:"big"` // Block type of result | 276 | Flags uint16 `order:"big"` // Message flags |
291 | Flags uint32 `order:"big"` // Message flags | 277 | Reserved uint16 `order:"big"` // Reserved |
292 | PutPathL uint16 `order:"big"` // size of PUTPATH field | 278 | PutPathL uint16 `order:"big"` // size of PUTPATH field |
293 | GetPathL uint16 `order:"big"` // size of GETPATH field | 279 | GetPathL uint16 `order:"big"` // size of GETPATH field |
294 | Expires util.AbsoluteTime `` // expiration date | 280 | Expire util.AbsoluteTime `` // expiration date |
295 | Query *crypto.HashCode `` // Query key for block | 281 | Query *crypto.HashCode `` // Query key for block |
296 | TruncOrigin *util.PeerID `opt:"(IsUsed)"` // truncated origin (if TRUNCATED flag set) | 282 | TruncOrigin *util.PeerID `opt:"(IsUsed)"` // truncated origin (if TRUNCATED flag set) |
297 | PathList []*path.Entry `size:"(NumPath)"` // PATH | 283 | PathList []*path.Entry `size:"(NumPath)"` // PATH |
298 | LastSig *util.PeerSignature `size:"(IsUsed)"` // signature of last hop (if RECORD_ROUTE flag is set) | 284 | LastSig *util.PeerSignature `opt:"(IsUsed)"` // signature of last hop (if RECORD_ROUTE flag is set) |
299 | Block []byte `size:"*"` // block data | 285 | Block []byte `size:"*"` // block data |
300 | } | 286 | } |
301 | 287 | ||
302 | // NewDHTP2PResultMsg creates a new empty DHTP2PResultMsg | 288 | // NewDHTP2PResultMsg creates a new empty DHTP2PResultMsg |
303 | func NewDHTP2PResultMsg() *DHTP2PResultMsg { | 289 | func NewDHTP2PResultMsg() *DHTP2PResultMsg { |
304 | return &DHTP2PResultMsg{ | 290 | return &DHTP2PResultMsg{ |
305 | MsgSize: 88, // size of empty message | 291 | MsgHeader: MsgHeader{88, enums.MSG_DHT_P2P_RESULT}, |
306 | MsgType: DHT_P2P_RESULT, // DHT_P2P_RESULT (148) | 292 | BType: enums.BLOCK_TYPE_ANY, // type of returned block |
307 | BType: uint32(enums.BLOCK_TYPE_ANY), // type of returned block | 293 | TruncOrigin: nil, // no truncated origin |
308 | TruncOrigin: nil, // no truncated origin | 294 | PutPathL: 0, // empty putpath |
309 | PutPathL: 0, // empty putpath | 295 | GetPathL: 0, // empty getpath |
310 | GetPathL: 0, // empty getpath | 296 | PathList: nil, // empty path list (put+get) |
311 | PathList: nil, // empty path list (put+get) | 297 | LastSig: nil, // no recorded route |
312 | LastSig: nil, // no recorded route | 298 | Block: nil, // empty block |
313 | Block: nil, // empty block | ||
314 | } | 299 | } |
315 | } | 300 | } |
316 | 301 | ||
@@ -337,7 +322,7 @@ func (m *DHTP2PResultMsg) NumPath(field string) uint { | |||
337 | // Path returns the current path from message | 322 | // Path returns the current path from message |
338 | func (m *DHTP2PResultMsg) Path(sender *util.PeerID) *path.Path { | 323 | func (m *DHTP2PResultMsg) Path(sender *util.PeerID) *path.Path { |
339 | // create a "real" path list from message data | 324 | // create a "real" path list from message data |
340 | pth := path.NewPath(crypto.Hash(m.Block), m.Expires) | 325 | pth := path.NewPath(crypto.Hash(m.Block), m.Expire) |
341 | 326 | ||
342 | // return empty path if recording is switched off | 327 | // return empty path if recording is switched off |
343 | if m.Flags&enums.DHT_RO_RECORD_ROUTE == 0 { | 328 | if m.Flags&enums.DHT_RO_RECORD_ROUTE == 0 { |
@@ -371,7 +356,7 @@ func (m *DHTP2PResultMsg) Path(sender *util.PeerID) *path.Path { | |||
371 | // handle last hop signature | 356 | // handle last hop signature |
372 | if m.LastSig == nil { | 357 | if m.LastSig == nil { |
373 | logger.Printf(logger.WARN, "[path] - last hop signature missing - path reset") | 358 | logger.Printf(logger.WARN, "[path] - last hop signature missing - path reset") |
374 | return path.NewPath(crypto.Hash(m.Block), m.Expires) | 359 | return path.NewPath(crypto.Hash(m.Block), m.Expire) |
375 | } | 360 | } |
376 | pth.Flags |= path.PathLastHop | 361 | pth.Flags |= path.PathLastHop |
377 | pth.LastSig = m.LastSig | 362 | pth.LastSig = m.LastSig |
@@ -433,13 +418,12 @@ func (m *DHTP2PResultMsg) SetPath(p *path.Path) { | |||
433 | func (m *DHTP2PResultMsg) Update(pth *path.Path) *DHTP2PResultMsg { | 418 | func (m *DHTP2PResultMsg) Update(pth *path.Path) *DHTP2PResultMsg { |
434 | // clone old message | 419 | // clone old message |
435 | msg := &DHTP2PResultMsg{ | 420 | msg := &DHTP2PResultMsg{ |
436 | MsgSize: m.MsgSize, | 421 | MsgHeader: MsgHeader{m.MsgSize, m.MsgType}, |
437 | MsgType: m.MsgType, | ||
438 | BType: m.BType, | 422 | BType: m.BType, |
439 | Flags: m.Flags, | 423 | Flags: m.Flags, |
440 | PutPathL: m.PutPathL, | 424 | PutPathL: m.PutPathL, |
441 | GetPathL: m.GetPathL, | 425 | GetPathL: m.GetPathL, |
442 | Expires: m.Expires, | 426 | Expire: m.Expire, |
443 | Query: m.Query.Clone(), | 427 | Query: m.Query.Clone(), |
444 | TruncOrigin: m.TruncOrigin, | 428 | TruncOrigin: m.TruncOrigin, |
445 | PathList: util.Clone(m.PathList), | 429 | PathList: util.Clone(m.PathList), |
@@ -455,13 +439,8 @@ func (m *DHTP2PResultMsg) Update(pth *path.Path) *DHTP2PResultMsg { | |||
455 | 439 | ||
456 | // String returns a human-readable representation of the message. | 440 | // String returns a human-readable representation of the message. |
457 | func (m *DHTP2PResultMsg) String() string { | 441 | func (m *DHTP2PResultMsg) String() string { |
458 | return fmt.Sprintf("DHTP2PResultMsg{btype=%s,putl=%d,getl=%d}", | 442 | return fmt.Sprintf("DHTP2PResultMsg{btype=%s,putl=%d,getl=%d,flags=%s}", |
459 | enums.BlockType(m.BType).String(), m.PutPathL, m.GetPathL) | 443 | m.BType, m.PutPathL, m.GetPathL, DHTFlags(uint16(m.Flags))) |
460 | } | ||
461 | |||
462 | // Header returns the message header in a separate instance. | ||
463 | func (m *DHTP2PResultMsg) Header() *Header { | ||
464 | return &Header{m.MsgSize, m.MsgType} | ||
465 | } | 444 | } |
466 | 445 | ||
467 | //---------------------------------------------------------------------- | 446 | //---------------------------------------------------------------------- |
@@ -474,26 +453,26 @@ func (m *DHTP2PResultMsg) Header() *Header { | |||
474 | 453 | ||
475 | // DHTP2PHelloMsg is a message send by peers to announce their presence | 454 | // DHTP2PHelloMsg is a message send by peers to announce their presence |
476 | type DHTP2PHelloMsg struct { | 455 | type DHTP2PHelloMsg struct { |
477 | MsgSize uint16 `order:"big"` // total size of message | 456 | MsgHeader |
478 | MsgType uint16 `order:"big"` // DHT_P2P_HELLO (157) | ||
479 | Reserved uint16 `order:"big"` // Reserved for further use | 457 | Reserved uint16 `order:"big"` // Reserved for further use |
480 | NumAddr uint16 `order:"big"` // Number of addresses in list | 458 | NumAddr uint16 `order:"big"` // Number of addresses in list |
481 | Signature *util.PeerSignature `` // Signature | 459 | Signature *util.PeerSignature `` // Signature |
482 | Expires util.AbsoluteTime `` // expiration time | 460 | Expire util.AbsoluteTime `` // expiration time |
483 | AddrList []byte `size:"*"` // List of end-point addresses (HelloAddress) | 461 | AddrList []byte `size:"*"` // List of end-point addresses (HelloAddress) |
484 | } | 462 | } |
485 | 463 | ||
486 | // NewHelloMsgDHT creates an empty DHT_P2P_HELLO message. | 464 | // NewHelloMsgDHT creates an empty DHT_P2P_HELLO message. |
487 | func NewDHTP2PHelloMsg() *DHTP2PHelloMsg { | 465 | func NewDHTP2PHelloMsg() *DHTP2PHelloMsg { |
488 | // return empty HelloMessage | 466 | // return empty HelloMessage with set expire date |
489 | exp := time.Now().Add(HelloAddressExpiration) | 467 | t := util.NewAbsoluteTime(time.Now().Add(HelloAddressExpiration)) |
468 | exp := util.NewAbsoluteTimeEpoch(t.Epoch()) | ||
469 | |||
490 | return &DHTP2PHelloMsg{ | 470 | return &DHTP2PHelloMsg{ |
491 | MsgSize: 80, // size without 'AddrList' | 471 | MsgHeader: MsgHeader{80, enums.MSG_DHT_P2P_HELLO}, |
492 | MsgType: DHT_P2P_HELLO, // DHT_P2P_HELLO (157) | ||
493 | Reserved: 0, // not used here | 472 | Reserved: 0, // not used here |
494 | NumAddr: 0, // start with empty address list | 473 | NumAddr: 0, // start with empty address list |
495 | Signature: util.NewPeerSignature(nil), // signature | 474 | Signature: util.NewPeerSignature(nil), // signature |
496 | Expires: util.NewAbsoluteTime(exp), // default expiration | 475 | Expire: exp, // default expiration |
497 | AddrList: make([]byte, 0), // list of addresses | 476 | AddrList: make([]byte, 0), // list of addresses |
498 | } | 477 | } |
499 | } | 478 | } |
@@ -511,7 +490,7 @@ func (m *DHTP2PHelloMsg) Addresses() (list []*util.Address, err error) { | |||
511 | if addr, err = util.ParseAddress(as); err != nil { | 490 | if addr, err = util.ParseAddress(as); err != nil { |
512 | return | 491 | return |
513 | } | 492 | } |
514 | addr.Expires = m.Expires | 493 | addr.Expire = m.Expire |
515 | list = append(list, addr) | 494 | list = append(list, addr) |
516 | num++ | 495 | num++ |
517 | } | 496 | } |
@@ -525,38 +504,26 @@ func (m *DHTP2PHelloMsg) Addresses() (list []*util.Address, err error) { | |||
525 | // SetAddresses adds addresses to the HELLO message. | 504 | // SetAddresses adds addresses to the HELLO message. |
526 | func (m *DHTP2PHelloMsg) SetAddresses(list []*util.Address) { | 505 | func (m *DHTP2PHelloMsg) SetAddresses(list []*util.Address) { |
527 | // write addresses as blob and track earliest expiration | 506 | // write addresses as blob and track earliest expiration |
528 | exp := util.NewAbsoluteTime(time.Now().Add(HelloAddressExpiration)) | 507 | t := util.NewAbsoluteTime(time.Now().Add(HelloAddressExpiration)) |
508 | exp := util.NewAbsoluteTimeEpoch(t.Epoch()) | ||
529 | wrt := new(bytes.Buffer) | 509 | wrt := new(bytes.Buffer) |
530 | for _, addr := range list { | 510 | for _, addr := range list { |
531 | // check if address expires before current expire | 511 | // check if address expires before current expire |
532 | if exp.Compare(addr.Expires) > 0 { | 512 | if exp.Compare(addr.Expire) > 0 { |
533 | exp = addr.Expires | 513 | exp = addr.Expire |
534 | } | 514 | } |
535 | n, _ := wrt.Write([]byte(addr.URI())) | 515 | n, _ := wrt.Write([]byte(addr.URI())) |
536 | wrt.WriteByte(0) | 516 | wrt.WriteByte(0) |
537 | m.MsgSize += uint16(n + 1) | 517 | m.MsgSize += uint16(n + 1) |
538 | } | 518 | } |
539 | m.AddrList = wrt.Bytes() | 519 | m.AddrList = wrt.Bytes() |
540 | m.Expires = exp | 520 | m.Expire = exp |
541 | m.NumAddr = uint16(len(list)) | 521 | m.NumAddr = uint16(len(list)) |
542 | } | 522 | } |
543 | 523 | ||
544 | // String returns a human-readable representation of the message. | 524 | // String returns a human-readable representation of the message. |
545 | func (m *DHTP2PHelloMsg) String() string { | 525 | func (m *DHTP2PHelloMsg) String() string { |
546 | addrs, _ := m.Addresses() | 526 | return fmt.Sprintf("DHTP2PHelloMsg{expire:%s,addrs=[%d]}", m.Expire, m.NumAddr) |
547 | aList := "" | ||
548 | for i, a := range addrs { | ||
549 | if i > 0 { | ||
550 | aList += "," | ||
551 | } | ||
552 | aList += a.URI() | ||
553 | } | ||
554 | return fmt.Sprintf("DHTP2PHelloMsg{expire:%s,addrs=%d:[%s]}", m.Expires, m.NumAddr, aList) | ||
555 | } | ||
556 | |||
557 | // Header returns the message header in a separate instance. | ||
558 | func (m *DHTP2PHelloMsg) Header() *Header { | ||
559 | return &Header{m.MsgSize, m.MsgType} | ||
560 | } | 527 | } |
561 | 528 | ||
562 | // Verify the message signature | 529 | // Verify the message signature |
@@ -590,7 +557,7 @@ func (m *DHTP2PHelloMsg) SignedData() []byte { | |||
590 | err := binary.Write(buf, binary.BigEndian, size) | 557 | err := binary.Write(buf, binary.BigEndian, size) |
591 | if err == nil { | 558 | if err == nil { |
592 | if err = binary.Write(buf, binary.BigEndian, purpose); err == nil { | 559 | if err = binary.Write(buf, binary.BigEndian, purpose); err == nil { |
593 | if err = binary.Write(buf, binary.BigEndian, m.Expires.Epoch()*1000000); err == nil { | 560 | if err = binary.Write(buf, binary.BigEndian, m.Expire); err == nil { |
594 | if n, err = buf.Write(hAddr[:]); err == nil { | 561 | if n, err = buf.Write(hAddr[:]); err == nil { |
595 | if n != len(hAddr[:]) { | 562 | if n != len(hAddr[:]) { |
596 | err = errors.New("write failed") | 563 | err = errors.New("write failed") |
@@ -604,3 +571,26 @@ func (m *DHTP2PHelloMsg) SignedData() []byte { | |||
604 | } | 571 | } |
605 | return buf.Bytes() | 572 | return buf.Bytes() |
606 | } | 573 | } |
574 | |||
575 | //---------------------------------------------------------------------- | ||
576 | // Helper functions | ||
577 | //---------------------------------------------------------------------- | ||
578 | |||
579 | // get human-readable flags | ||
580 | func DHTFlags(flags uint16) string { | ||
581 | var list []string | ||
582 | if flags&enums.DHT_RO_DEMULTIPLEX_EVERYWHERE != 0 { | ||
583 | list = append(list, "DEMUX") | ||
584 | } | ||
585 | if flags&enums.DHT_RO_RECORD_ROUTE != 0 { | ||
586 | list = append(list, "ROUTE") | ||
587 | } | ||
588 | if flags&enums.DHT_RO_FIND_APPROXIMATE != 0 { | ||
589 | list = append(list, "APPROX") | ||
590 | } | ||
591 | if flags&enums.DHT_RO_TRUNCATED != 0 { | ||
592 | list = append(list, "TRUNC") | ||
593 | } | ||
594 | s := strings.Join(list, "|") | ||
595 | return "<" + s + ">" | ||
596 | } | ||
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 ( | |||
34 | 34 | ||
35 | // LookupMsg is a request message for a GNS name lookup | 35 | // LookupMsg is a request message for a GNS name lookup |
36 | type LookupMsg struct { | 36 | type LookupMsg struct { |
37 | MsgSize uint16 `order:"big"` // total size of message | 37 | MsgHeader |
38 | MsgType uint16 `order:"big"` // GNS_LOOKUP (500) | ||
39 | ID uint32 `order:"big"` // Unique identifier for this request (for key collisions). | 38 | ID uint32 `order:"big"` // Unique identifier for this request (for key collisions). |
40 | Zone *crypto.ZoneKey `` // Zone that is to be used for lookup | 39 | Zone *crypto.ZoneKey `` // Zone that is to be used for lookup |
41 | Options uint16 `order:"big"` // Local options for where to look for results | 40 | Options uint16 `order:"big"` // Local options for where to look for results |
42 | Reserved uint16 `order:"big"` // Always 0 | 41 | Reserved uint16 `order:"big"` // Always 0 |
43 | Type uint32 `order:"big"` // the type of record to look up | 42 | RType uint32 `order:"big"` // the type of record to look up |
44 | Name []byte `size:"*"` // zero-terminated name to look up | 43 | Name []byte `size:"*"` // zero-terminated name to look up |
45 | } | 44 | } |
46 | 45 | ||
47 | // NewGNSLookupMsg creates a new default message. | 46 | // NewGNSLookupMsg creates a new default message. |
48 | func NewGNSLookupMsg() *LookupMsg { | 47 | func NewGNSLookupMsg() *LookupMsg { |
49 | return &LookupMsg{ | 48 | return &LookupMsg{ |
50 | MsgSize: 48, // record size with no name | 49 | MsgHeader: MsgHeader{48, enums.MSG_GNS_LOOKUP}, |
51 | MsgType: GNS_LOOKUP, | 50 | ID: 0, |
52 | ID: 0, | 51 | Zone: nil, |
53 | Zone: nil, | 52 | Options: uint16(enums.GNS_LO_DEFAULT), |
54 | Options: uint16(enums.GNS_LO_DEFAULT), | 53 | Reserved: 0, |
55 | Reserved: 0, | 54 | RType: uint32(enums.GNS_TYPE_ANY), |
56 | Type: uint32(enums.GNS_TYPE_ANY), | 55 | Name: nil, |
57 | Name: nil, | ||
58 | } | 56 | } |
59 | } | 57 | } |
60 | 58 | ||
@@ -79,12 +77,7 @@ func (m *LookupMsg) GetName() string { | |||
79 | func (m *LookupMsg) String() string { | 77 | func (m *LookupMsg) String() string { |
80 | return fmt.Sprintf( | 78 | return fmt.Sprintf( |
81 | "GNSLookupMsg{Id=%d,Zone=%s,Options=%d,Type=%d,Name=%s}", | 79 | "GNSLookupMsg{Id=%d,Zone=%s,Options=%d,Type=%d,Name=%s}", |
82 | m.ID, m.Zone.ID(), m.Options, m.Type, m.GetName()) | 80 | m.ID, m.Zone.ID(), m.Options, m.RType, m.GetName()) |
83 | } | ||
84 | |||
85 | // Header returns the message header in a separate instance. | ||
86 | func (m *LookupMsg) Header() *Header { | ||
87 | return &Header{m.MsgSize, m.MsgType} | ||
88 | } | 81 | } |
89 | 82 | ||
90 | //---------------------------------------------------------------------- | 83 | //---------------------------------------------------------------------- |
@@ -128,14 +121,14 @@ func (rs *RecordSet) SetPadding() { | |||
128 | rs.Padding = make([]byte, n-size) | 121 | rs.Padding = make([]byte, n-size) |
129 | } | 122 | } |
130 | 123 | ||
131 | // Expires returns the earliest expiration timestamp for the records. | 124 | // Expire returns the earliest expiration timestamp for the records. |
132 | func (rs *RecordSet) Expires() util.AbsoluteTime { | 125 | func (rs *RecordSet) Expire() util.AbsoluteTime { |
133 | var expires util.AbsoluteTime | 126 | var expires util.AbsoluteTime |
134 | for i, rr := range rs.Records { | 127 | for i, rr := range rs.Records { |
135 | if i == 0 { | 128 | if i == 0 { |
136 | expires = rr.Expires | 129 | expires = rr.Expire |
137 | } else if rr.Expires.Compare(expires) < 0 { | 130 | } else if rr.Expire.Compare(expires) < 0 { |
138 | expires = rr.Expires | 131 | expires = rr.Expire |
139 | } | 132 | } |
140 | } | 133 | } |
141 | return expires | 134 | return expires |
@@ -144,23 +137,22 @@ func (rs *RecordSet) Expires() util.AbsoluteTime { | |||
144 | // ResourceRecord is the GNUnet-specific representation of resource | 137 | // ResourceRecord is the GNUnet-specific representation of resource |
145 | // records (not to be confused with DNS resource records). | 138 | // records (not to be confused with DNS resource records). |
146 | type ResourceRecord struct { | 139 | type ResourceRecord struct { |
147 | Expires util.AbsoluteTime // Expiration time for the record | 140 | Expire util.AbsoluteTime // Expiration time for the record |
148 | Size uint32 `order:"big"` // Number of bytes in 'Data' | 141 | Size uint32 `order:"big"` // Number of bytes in 'Data' |
149 | Type uint32 `order:"big"` // Type of the GNS/DNS record | 142 | RType uint32 `order:"big"` // Type of the GNS/DNS record |
150 | Flags uint32 `order:"big"` // Flags for the record | 143 | Flags uint32 `order:"big"` // Flags for the record |
151 | Data []byte `size:"Size"` // Record data | 144 | Data []byte `size:"Size"` // Record data |
152 | } | 145 | } |
153 | 146 | ||
154 | // String returns a human-readable representation of the message. | 147 | // String returns a human-readable representation of the message. |
155 | func (r *ResourceRecord) String() string { | 148 | func (r *ResourceRecord) String() string { |
156 | return fmt.Sprintf("GNSResourceRecord{type=%s,expire=%s,flags=%d,size=%d}", | 149 | return fmt.Sprintf("GNSResourceRecord{type=%s,expire=%s,flags=%d,size=%d}", |
157 | enums.GNSType(r.Type).String(), r.Expires, r.Flags, r.Size) | 150 | enums.GNSType(r.RType).String(), r.Expire, r.Flags, r.Size) |
158 | } | 151 | } |
159 | 152 | ||
160 | // LookupResultMsg is a response message for a GNS name lookup request | 153 | // LookupResultMsg is a response message for a GNS name lookup request |
161 | type LookupResultMsg struct { | 154 | type LookupResultMsg struct { |
162 | MsgSize uint16 `order:"big"` // total size of message | 155 | MsgHeader |
163 | MsgType uint16 `order:"big"` // GNS_LOOKUP_RESULT (501) | ||
164 | ID uint32 `order:"big"` // Unique identifier for this request (for key collisions). | 156 | ID uint32 `order:"big"` // Unique identifier for this request (for key collisions). |
165 | Count uint32 `order:"big"` // The number of records contained in response | 157 | Count uint32 `order:"big"` // The number of records contained in response |
166 | Records []*ResourceRecord `size:"Count"` // GNS resource records | 158 | Records []*ResourceRecord `size:"Count"` // GNS resource records |
@@ -169,11 +161,10 @@ type LookupResultMsg struct { | |||
169 | // NewGNSLookupResultMsg returns a new lookup result message | 161 | // NewGNSLookupResultMsg returns a new lookup result message |
170 | func NewGNSLookupResultMsg(id uint32) *LookupResultMsg { | 162 | func NewGNSLookupResultMsg(id uint32) *LookupResultMsg { |
171 | return &LookupResultMsg{ | 163 | return &LookupResultMsg{ |
172 | MsgSize: 12, // Empty result (no records) | 164 | MsgHeader: MsgHeader{12, enums.MSG_GNS_LOOKUP_RESULT}, |
173 | MsgType: GNS_LOOKUP_RESULT, | 165 | ID: id, |
174 | ID: id, | 166 | Count: 0, |
175 | Count: 0, | 167 | Records: make([]*ResourceRecord, 0), |
176 | Records: make([]*ResourceRecord, 0), | ||
177 | } | 168 | } |
178 | } | 169 | } |
179 | 170 | ||
@@ -195,6 +186,6 @@ func (m *LookupResultMsg) String() string { | |||
195 | } | 186 | } |
196 | 187 | ||
197 | // Header returns the message header in a separate instance. | 188 | // Header returns the message header in a separate instance. |
198 | func (m *LookupResultMsg) Header() *Header { | 189 | func (m *LookupResultMsg) Header() *MsgHeader { |
199 | return &Header{m.MsgSize, m.MsgType} | 190 | return &MsgHeader{m.MsgSize, m.MsgType} |
200 | } | 191 | } |
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) { | |||
54 | Count: 2, | 54 | Count: 2, |
55 | Records: []*ResourceRecord{ | 55 | Records: []*ResourceRecord{ |
56 | { | 56 | { |
57 | Expires: util.AbsoluteTime{ | 57 | Expire: util.AbsoluteTime{ |
58 | Val: uint64(14888744139323793), | 58 | Val: uint64(14888744139323793), |
59 | }, | 59 | }, |
60 | Size: 4, | 60 | Size: 4, |
61 | Type: 1, | 61 | RType: 1, |
62 | Flags: 0, | 62 | Flags: 0, |
63 | Data: []byte{ | 63 | Data: []byte{ |
64 | 0x01, 0x02, 0x03, 0x04, | 64 | 0x01, 0x02, 0x03, 0x04, |
65 | }, | 65 | }, |
66 | }, | 66 | }, |
67 | { | 67 | { |
68 | Expires: util.AbsoluteTime{ | 68 | Expire: util.AbsoluteTime{ |
69 | Val: uint64(26147096139323793), | 69 | Val: uint64(26147096139323793), |
70 | }, | 70 | }, |
71 | Size: 36, | 71 | Size: 36, |
72 | Type: crypto.ZONE_PKEY, | 72 | RType: crypto.ZONE_PKEY, |
73 | Flags: 2, | 73 | Flags: 2, |
74 | Data: []byte{ | 74 | Data: []byte{ |
75 | 0x00, 0x01, 0x00, 0x00, | 75 | 0x00, 0x01, 0x00, 0x00, |
@@ -164,7 +164,7 @@ func TestRecordsetPKEY(t *testing.T) { | |||
164 | } | 164 | } |
165 | 165 | ||
166 | // check symmetric keys and nonce | 166 | // check symmetric keys and nonce |
167 | expires := RECSET.Expires() | 167 | expires := RECSET.Expire() |
168 | skey := zk.BlockKey(LABEL, expires) | 168 | skey := zk.BlockKey(LABEL, expires) |
169 | if !bytes.Equal(skey[32:], NONCE) { | 169 | if !bytes.Equal(skey[32:], NONCE) { |
170 | t.Logf("nonce = %s\n", hex.EncodeToString(skey[32:])) | 170 | t.Logf("nonce = %s\n", hex.EncodeToString(skey[32:])) |
@@ -214,22 +214,22 @@ func TestRecordsetEDKEY(t *testing.T) { | |||
214 | Count: 2, | 214 | Count: 2, |
215 | Records: []*ResourceRecord{ | 215 | Records: []*ResourceRecord{ |
216 | { | 216 | { |
217 | Expires: util.AbsoluteTime{ | 217 | Expire: util.AbsoluteTime{ |
218 | Val: uint64(2463385894000000), | 218 | Val: uint64(2463385894000000), |
219 | }, | 219 | }, |
220 | Size: 4, | 220 | Size: 4, |
221 | Type: 1, | 221 | RType: 1, |
222 | Flags: 0, | 222 | Flags: 0, |
223 | Data: []byte{ | 223 | Data: []byte{ |
224 | 0x01, 0x02, 0x03, 0x04, | 224 | 0x01, 0x02, 0x03, 0x04, |
225 | }, | 225 | }, |
226 | }, | 226 | }, |
227 | { | 227 | { |
228 | Expires: util.AbsoluteTime{ | 228 | Expire: util.AbsoluteTime{ |
229 | Val: uint64(49556645701000000), | 229 | Val: uint64(49556645701000000), |
230 | }, | 230 | }, |
231 | Size: 36, | 231 | Size: 36, |
232 | Type: uint32(enums.GNS_TYPE_NICK), | 232 | RType: uint32(enums.GNS_TYPE_NICK), |
233 | Flags: 2, | 233 | Flags: 2, |
234 | Data: []byte{ | 234 | Data: []byte{ |
235 | 0x4d, 0x79, 0x20, 0x4e, 0x69, 0x63, 0x6b, 0x00, | 235 | 0x4d, 0x79, 0x20, 0x4e, 0x69, 0x63, 0x6b, 0x00, |
@@ -327,7 +327,7 @@ func TestRecordsetEDKEY(t *testing.T) { | |||
327 | } | 327 | } |
328 | 328 | ||
329 | // check symmetric keys and nonce | 329 | // check symmetric keys and nonce |
330 | expires := RECSET.Expires() | 330 | expires := RECSET.Expire() |
331 | skey := zk.BlockKey(LABEL, expires) | 331 | skey := zk.BlockKey(LABEL, expires) |
332 | if !bytes.Equal(skey[32:], NONCE) { | 332 | if !bytes.Equal(skey[32:], NONCE) { |
333 | t.Logf("nonce = %s\n", hex.EncodeToString(skey[32:])) | 333 | 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 ( | |||
22 | "bytes" | 22 | "bytes" |
23 | "encoding/binary" | 23 | "encoding/binary" |
24 | "fmt" | 24 | "fmt" |
25 | "gnunet/enums" | ||
25 | "gnunet/util" | 26 | "gnunet/util" |
26 | "io" | 27 | "io" |
27 | "time" | 28 | "time" |
@@ -43,8 +44,8 @@ type HelloAddress struct { | |||
43 | func NewHelloAddress(a *util.Address) *HelloAddress { | 44 | func NewHelloAddress(a *util.Address) *HelloAddress { |
44 | // use default expiration time, but adjust it if address expires earlier | 45 | // use default expiration time, but adjust it if address expires earlier |
45 | exp := util.NewAbsoluteTime(time.Now().Add(HelloAddressExpiration)) | 46 | exp := util.NewAbsoluteTime(time.Now().Add(HelloAddressExpiration)) |
46 | if exp.Compare(a.Expires) > 0 { | 47 | if exp.Compare(a.Expire) > 0 { |
47 | exp = a.Expires | 48 | exp = a.Expire |
48 | } | 49 | } |
49 | // convert address | 50 | // convert address |
50 | addr := &HelloAddress{ | 51 | addr := &HelloAddress{ |
@@ -101,7 +102,7 @@ func ParseHelloAddr(rdr io.Reader) (a *HelloAddress, err error) { | |||
101 | // Wrap a HelloAddress into a uitl.Address | 102 | // Wrap a HelloAddress into a uitl.Address |
102 | func (a *HelloAddress) Wrap() (addr *util.Address) { | 103 | func (a *HelloAddress) Wrap() (addr *util.Address) { |
103 | addr = util.NewAddress(a.transport, string(a.address)) | 104 | addr = util.NewAddress(a.transport, string(a.address)) |
104 | addr.Expires = a.expires | 105 | addr.Expire = a.expires |
105 | return | 106 | return |
106 | } | 107 | } |
107 | 108 | ||
@@ -140,8 +141,7 @@ func (a *HelloAddress) Bytes() []byte { | |||
140 | 141 | ||
141 | // HelloMsg is a message send by peers to announce their presence | 142 | // HelloMsg is a message send by peers to announce their presence |
142 | type HelloMsg struct { | 143 | type HelloMsg struct { |
143 | MsgSize uint16 `order:"big"` // total size of message | 144 | MsgHeader |
144 | MsgType uint16 `order:"big"` // HELLO (17) | ||
145 | FriendsOnly uint32 `order:"big"` // Do not gossip this HELLO message | 145 | FriendsOnly uint32 `order:"big"` // Do not gossip this HELLO message |
146 | Peer *util.PeerID `` // peer identifier for addresses | 146 | Peer *util.PeerID `` // peer identifier for addresses |
147 | AddrList []byte `size:"*"` // List of end-point addresses (HelloAddress) | 147 | AddrList []byte `size:"*"` // List of end-point addresses (HelloAddress) |
@@ -155,8 +155,7 @@ func NewHelloMsg(peer *util.PeerID) *HelloMsg { | |||
155 | } | 155 | } |
156 | // return empty HelloMessage | 156 | // return empty HelloMessage |
157 | return &HelloMsg{ | 157 | return &HelloMsg{ |
158 | MsgSize: 40, // size without 'AddrList' | 158 | MsgHeader: MsgHeader{40, enums.MSG_HELLO}, |
159 | MsgType: HELLO, // HELLO (17) | ||
160 | FriendsOnly: 0, // not used here | 159 | FriendsOnly: 0, // not used here |
161 | Peer: peer, // associated peer | 160 | Peer: peer, // associated peer |
162 | AddrList: make([]byte, 0), // list of addresses | 161 | AddrList: make([]byte, 0), // list of addresses |
@@ -194,8 +193,3 @@ func (m *HelloMsg) SetAddresses(list []*HelloAddress) { | |||
194 | } | 193 | } |
195 | m.AddrList = wrt.Bytes() | 194 | m.AddrList = wrt.Bytes() |
196 | } | 195 | } |
197 | |||
198 | // Header returns the message header in a separate instance. | ||
199 | func (m *HelloMsg) Header() *Header { | ||
200 | return &Header{m.MsgSize, m.MsgType} | ||
201 | } | ||
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 ( | |||
22 | "encoding/hex" | 22 | "encoding/hex" |
23 | "fmt" | 23 | "fmt" |
24 | "gnunet/crypto" | 24 | "gnunet/crypto" |
25 | "gnunet/enums" | ||
25 | "gnunet/service/dht/blocks" | 26 | "gnunet/service/dht/blocks" |
26 | "gnunet/util" | 27 | "gnunet/util" |
27 | ) | 28 | ) |
@@ -32,10 +33,9 @@ import ( | |||
32 | 33 | ||
33 | // NamecacheLookupMsg is request message for lookups in local namecache | 34 | // NamecacheLookupMsg is request message for lookups in local namecache |
34 | type NamecacheLookupMsg struct { | 35 | type NamecacheLookupMsg struct { |
35 | MsgSize uint16 `order:"big"` // total size of message | 36 | MsgHeader |
36 | MsgType uint16 `order:"big"` // NAMECACHE_LOOKUP_BLOCK (431) | 37 | ID uint32 `order:"big"` // Request Id |
37 | ID uint32 `order:"big"` // Request Id | 38 | Query *crypto.HashCode // Query data |
38 | Query *crypto.HashCode // Query data | ||
39 | } | 39 | } |
40 | 40 | ||
41 | // NewNamecacheLookupMsg creates a new default message. | 41 | // NewNamecacheLookupMsg creates a new default message. |
@@ -44,22 +44,16 @@ func NewNamecacheLookupMsg(query *crypto.HashCode) *NamecacheLookupMsg { | |||
44 | query = crypto.NewHashCode(nil) | 44 | query = crypto.NewHashCode(nil) |
45 | } | 45 | } |
46 | return &NamecacheLookupMsg{ | 46 | return &NamecacheLookupMsg{ |
47 | MsgSize: 72, | 47 | MsgHeader: MsgHeader{72, enums.MSG_NAMECACHE_LOOKUP_BLOCK}, |
48 | MsgType: NAMECACHE_LOOKUP_BLOCK, | 48 | ID: 0, |
49 | ID: 0, | 49 | Query: query, |
50 | Query: query, | ||
51 | } | 50 | } |
52 | } | 51 | } |
53 | 52 | ||
54 | // String returns a human-readable representation of the message. | 53 | // String returns a human-readable representation of the message. |
55 | func (m *NamecacheLookupMsg) String() string { | 54 | func (m *NamecacheLookupMsg) String() string { |
56 | return fmt.Sprintf("NamecacheLookupMsg{Id=%d,Query=%s}", | 55 | return fmt.Sprintf("NamecacheLookupMsg{Id=%d,Query=%s}", |
57 | m.ID, hex.EncodeToString(m.Query.Bits)) | 56 | m.ID, hex.EncodeToString(m.Query.Data)) |
58 | } | ||
59 | |||
60 | // Header returns the message header in a separate instance. | ||
61 | func (m *NamecacheLookupMsg) Header() *Header { | ||
62 | return &Header{m.MsgSize, m.MsgType} | ||
63 | } | 57 | } |
64 | 58 | ||
65 | //---------------------------------------------------------------------- | 59 | //---------------------------------------------------------------------- |
@@ -68,8 +62,7 @@ func (m *NamecacheLookupMsg) Header() *Header { | |||
68 | 62 | ||
69 | // NamecacheLookupResultMsg is the response message for namecache lookups. | 63 | // NamecacheLookupResultMsg is the response message for namecache lookups. |
70 | type NamecacheLookupResultMsg struct { | 64 | type NamecacheLookupResultMsg struct { |
71 | MsgSize uint16 `order:"big"` // total size of message | 65 | MsgHeader |
72 | MsgType uint16 `order:"big"` // NAMECACHE_LOOKUP_BLOCK_RESPONSE (432) | ||
73 | ID uint32 `order:"big"` // Request Id | 66 | ID uint32 `order:"big"` // Request Id |
74 | Expire util.AbsoluteTime `` // Expiration time | 67 | Expire util.AbsoluteTime `` // Expiration time |
75 | DerivedKeySig *crypto.ZoneSignature `` // Derived public key | 68 | DerivedKeySig *crypto.ZoneSignature `` // Derived public key |
@@ -79,8 +72,7 @@ type NamecacheLookupResultMsg struct { | |||
79 | // NewNamecacheLookupResultMsg creates a new default message. | 72 | // NewNamecacheLookupResultMsg creates a new default message. |
80 | func NewNamecacheLookupResultMsg() *NamecacheLookupResultMsg { | 73 | func NewNamecacheLookupResultMsg() *NamecacheLookupResultMsg { |
81 | return &NamecacheLookupResultMsg{ | 74 | return &NamecacheLookupResultMsg{ |
82 | MsgSize: 112, | 75 | MsgHeader: MsgHeader{112, enums.MSG_NAMECACHE_LOOKUP_BLOCK_RESPONSE}, |
83 | MsgType: NAMECACHE_LOOKUP_BLOCK_RESPONSE, | ||
84 | ID: 0, | 76 | ID: 0, |
85 | Expire: *new(util.AbsoluteTime), | 77 | Expire: *new(util.AbsoluteTime), |
86 | DerivedKeySig: nil, | 78 | DerivedKeySig: nil, |
@@ -94,19 +86,13 @@ func (m *NamecacheLookupResultMsg) String() string { | |||
94 | m.ID, m.Expire) | 86 | m.ID, m.Expire) |
95 | } | 87 | } |
96 | 88 | ||
97 | // Header returns the message header in a separate instance. | ||
98 | func (m *NamecacheLookupResultMsg) Header() *Header { | ||
99 | return &Header{m.MsgSize, m.MsgType} | ||
100 | } | ||
101 | |||
102 | //---------------------------------------------------------------------- | 89 | //---------------------------------------------------------------------- |
103 | // NAMECACHE_CACHE_BLOCK | 90 | // NAMECACHE_CACHE_BLOCK |
104 | //---------------------------------------------------------------------- | 91 | //---------------------------------------------------------------------- |
105 | 92 | ||
106 | // NamecacheCacheMsg is the request message to put a name into the local cache. | 93 | // NamecacheCacheMsg is the request message to put a name into the local cache. |
107 | type NamecacheCacheMsg struct { | 94 | type NamecacheCacheMsg struct { |
108 | MsgSize uint16 `order:"big"` // total size of message | 95 | MsgHeader |
109 | MsgType uint16 `order:"big"` // NAMECACHE_CACHE_BLOCK (433) | ||
110 | ID uint32 `order:"big"` // Request Id | 96 | ID uint32 `order:"big"` // Request Id |
111 | Expire util.AbsoluteTime `` // Expiration time | 97 | Expire util.AbsoluteTime `` // Expiration time |
112 | DerivedKeySig *crypto.ZoneSignature `` // Derived public key and signature | 98 | DerivedKeySig *crypto.ZoneSignature `` // Derived public key and signature |
@@ -116,8 +102,7 @@ type NamecacheCacheMsg struct { | |||
116 | // NewNamecacheCacheMsg creates a new default message. | 102 | // NewNamecacheCacheMsg creates a new default message. |
117 | func NewNamecacheCacheMsg(block *blocks.GNSBlock) *NamecacheCacheMsg { | 103 | func NewNamecacheCacheMsg(block *blocks.GNSBlock) *NamecacheCacheMsg { |
118 | msg := &NamecacheCacheMsg{ | 104 | msg := &NamecacheCacheMsg{ |
119 | MsgSize: 108, | 105 | MsgHeader: MsgHeader{108, enums.MSG_NAMECACHE_BLOCK_CACHE}, |
120 | MsgType: NAMECACHE_BLOCK_CACHE, | ||
121 | ID: 0, | 106 | ID: 0, |
122 | Expire: *new(util.AbsoluteTime), | 107 | Expire: *new(util.AbsoluteTime), |
123 | DerivedKeySig: nil, | 108 | DerivedKeySig: nil, |
@@ -140,30 +125,23 @@ func (m *NamecacheCacheMsg) String() string { | |||
140 | m.ID, m.Expire) | 125 | m.ID, m.Expire) |
141 | } | 126 | } |
142 | 127 | ||
143 | // Header returns the message header in a separate instance. | ||
144 | func (m *NamecacheCacheMsg) Header() *Header { | ||
145 | return &Header{m.MsgSize, m.MsgType} | ||
146 | } | ||
147 | |||
148 | //---------------------------------------------------------------------- | 128 | //---------------------------------------------------------------------- |
149 | // NAMECACHE_BLOCK_CACHE_RESPONSE | 129 | // NAMECACHE_BLOCK_CACHE_RESPONSE |
150 | //---------------------------------------------------------------------- | 130 | //---------------------------------------------------------------------- |
151 | 131 | ||
152 | // NamecacheCacheResponseMsg is the response message for a put request | 132 | // NamecacheCacheResponseMsg is the response message for a put request |
153 | type NamecacheCacheResponseMsg struct { | 133 | type NamecacheCacheResponseMsg struct { |
154 | MsgSize uint16 `order:"big"` // total size of message | 134 | MsgHeader |
155 | MsgType uint16 `order:"big"` // NAMECACHE_LOOKUP_BLOCK_RESPONSE (432) | 135 | ID uint32 `order:"big"` // Request Id |
156 | ID uint32 `order:"big"` // Request Id | 136 | Result int32 `order:"big"` // Result code |
157 | Result int32 `order:"big"` // Result code | ||
158 | } | 137 | } |
159 | 138 | ||
160 | // NewNamecacheCacheResponseMsg creates a new default message. | 139 | // NewNamecacheCacheResponseMsg creates a new default message. |
161 | func NewNamecacheCacheResponseMsg() *NamecacheCacheResponseMsg { | 140 | func NewNamecacheCacheResponseMsg() *NamecacheCacheResponseMsg { |
162 | return &NamecacheCacheResponseMsg{ | 141 | return &NamecacheCacheResponseMsg{ |
163 | MsgSize: 12, | 142 | MsgHeader: MsgHeader{12, enums.MSG_NAMECACHE_BLOCK_CACHE_RESPONSE}, |
164 | MsgType: NAMECACHE_BLOCK_CACHE_RESPONSE, | 143 | ID: 0, |
165 | ID: 0, | 144 | Result: 0, |
166 | Result: 0, | ||
167 | } | 145 | } |
168 | } | 146 | } |
169 | 147 | ||
@@ -172,8 +150,3 @@ func (m *NamecacheCacheResponseMsg) String() string { | |||
172 | return fmt.Sprintf("NamecacheCacheResponseMsg{id=%d,result=%d}", | 150 | return fmt.Sprintf("NamecacheCacheResponseMsg{id=%d,result=%d}", |
173 | m.ID, m.Result) | 151 | m.ID, m.Result) |
174 | } | 152 | } |
175 | |||
176 | // Header returns the message header in a separate instance. | ||
177 | func (m *NamecacheCacheResponseMsg) Header() *Header { | ||
178 | return &Header{m.MsgSize, m.MsgType} | ||
179 | } | ||
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 ( | |||
22 | "fmt" | 22 | "fmt" |
23 | 23 | ||
24 | "gnunet/crypto" | 24 | "gnunet/crypto" |
25 | "gnunet/enums" | ||
25 | "gnunet/util" | 26 | "gnunet/util" |
26 | ) | 27 | ) |
27 | 28 | ||
@@ -31,8 +32,7 @@ import ( | |||
31 | 32 | ||
32 | // RevocationQueryMsg is a request message to check if a key is revoked | 33 | // RevocationQueryMsg is a request message to check if a key is revoked |
33 | type RevocationQueryMsg struct { | 34 | type RevocationQueryMsg struct { |
34 | MsgSize uint16 `order:"big"` // total size of message | 35 | MsgHeader |
35 | MsgType uint16 `order:"big"` // REVOCATION_QUERY (636) | ||
36 | Reserved uint32 `order:"big"` // Reserved for future use | 36 | Reserved uint32 `order:"big"` // Reserved for future use |
37 | Zone *crypto.ZoneKey // Zone that is to be checked for revocation | 37 | Zone *crypto.ZoneKey // Zone that is to be checked for revocation |
38 | } | 38 | } |
@@ -40,10 +40,9 @@ type RevocationQueryMsg struct { | |||
40 | // NewRevocationQueryMsg creates a new message for a given zone. | 40 | // NewRevocationQueryMsg creates a new message for a given zone. |
41 | func NewRevocationQueryMsg(zkey *crypto.ZoneKey) *RevocationQueryMsg { | 41 | func NewRevocationQueryMsg(zkey *crypto.ZoneKey) *RevocationQueryMsg { |
42 | return &RevocationQueryMsg{ | 42 | return &RevocationQueryMsg{ |
43 | MsgSize: 40, | 43 | MsgHeader: MsgHeader{40, enums.MSG_REVOCATION_QUERY}, |
44 | MsgType: REVOCATION_QUERY, | 44 | Reserved: 0, |
45 | Reserved: 0, | 45 | Zone: zkey, |
46 | Zone: zkey, | ||
47 | } | 46 | } |
48 | } | 47 | } |
49 | 48 | ||
@@ -52,20 +51,14 @@ func (m *RevocationQueryMsg) String() string { | |||
52 | return fmt.Sprintf("RevocationQueryMsg{zone=%s}", m.Zone.ID()) | 51 | return fmt.Sprintf("RevocationQueryMsg{zone=%s}", m.Zone.ID()) |
53 | } | 52 | } |
54 | 53 | ||
55 | // Header returns the message header in a separate instance. | ||
56 | func (m *RevocationQueryMsg) Header() *Header { | ||
57 | return &Header{m.MsgSize, m.MsgType} | ||
58 | } | ||
59 | |||
60 | //---------------------------------------------------------------------- | 54 | //---------------------------------------------------------------------- |
61 | // REVOCATION_QUERY_RESPONSE | 55 | // REVOCATION_QUERY_RESPONSE |
62 | //---------------------------------------------------------------------- | 56 | //---------------------------------------------------------------------- |
63 | 57 | ||
64 | // RevocationQueryResponseMsg is a response message for revocation checks. | 58 | // RevocationQueryResponseMsg is a response message for revocation checks. |
65 | type RevocationQueryResponseMsg struct { | 59 | type RevocationQueryResponseMsg struct { |
66 | MsgSize uint16 `order:"big"` // total size of message | 60 | MsgHeader |
67 | MsgType uint16 `order:"big"` // REVOCATION_QUERY_RESPONSE (637) | 61 | Valid uint32 `order:"big"` // revoked(0), valid(1) |
68 | Valid uint32 `order:"big"` // revoked(0), valid(1) | ||
69 | } | 62 | } |
70 | 63 | ||
71 | // NewRevocationQueryResponseMsg creates a new response for a query. | 64 | // NewRevocationQueryResponseMsg creates a new response for a query. |
@@ -75,9 +68,8 @@ func NewRevocationQueryResponseMsg(revoked bool) *RevocationQueryResponseMsg { | |||
75 | valid = 0 | 68 | valid = 0 |
76 | } | 69 | } |
77 | return &RevocationQueryResponseMsg{ | 70 | return &RevocationQueryResponseMsg{ |
78 | MsgSize: 8, | 71 | MsgHeader: MsgHeader{8, enums.MSG_REVOCATION_QUERY_RESPONSE}, |
79 | MsgType: REVOCATION_QUERY_RESPONSE, | 72 | Valid: uint32(valid), |
80 | Valid: uint32(valid), | ||
81 | } | 73 | } |
82 | } | 74 | } |
83 | 75 | ||
@@ -86,19 +78,13 @@ func (m *RevocationQueryResponseMsg) String() string { | |||
86 | return fmt.Sprintf("RevocationQueryResponseMsg{valid=%d}", m.Valid) | 78 | return fmt.Sprintf("RevocationQueryResponseMsg{valid=%d}", m.Valid) |
87 | } | 79 | } |
88 | 80 | ||
89 | // Header returns the message header in a separate instance. | ||
90 | func (m *RevocationQueryResponseMsg) Header() *Header { | ||
91 | return &Header{m.MsgSize, m.MsgType} | ||
92 | } | ||
93 | |||
94 | //---------------------------------------------------------------------- | 81 | //---------------------------------------------------------------------- |
95 | // REVOCATION_REVOKE | 82 | // REVOCATION_REVOKE |
96 | //---------------------------------------------------------------------- | 83 | //---------------------------------------------------------------------- |
97 | 84 | ||
98 | // RevocationRevokeMsg is a request to revoke a given key with PoW data | 85 | // RevocationRevokeMsg is a request to revoke a given key with PoW data |
99 | type RevocationRevokeMsg struct { | 86 | type RevocationRevokeMsg struct { |
100 | MsgSize uint16 `order:"big"` // total size of message | 87 | MsgHeader |
101 | MsgType uint16 `order:"big"` // REVOCATION_REVOKE (638) | ||
102 | Timestamp util.AbsoluteTime `` // Timestamp of revocation creation | 88 | Timestamp util.AbsoluteTime `` // Timestamp of revocation creation |
103 | TTL util.RelativeTime `` // TTL of revocation | 89 | TTL util.RelativeTime `` // TTL of revocation |
104 | PoWs []uint64 `size:"32" order:"big"` // (Sorted) list of PoW values | 90 | PoWs []uint64 `size:"32" order:"big"` // (Sorted) list of PoW values |
@@ -108,8 +94,7 @@ type RevocationRevokeMsg struct { | |||
108 | // NewRevocationRevokeMsg creates a new message for a given zone. | 94 | // NewRevocationRevokeMsg creates a new message for a given zone. |
109 | func NewRevocationRevokeMsg(zsig *crypto.ZoneSignature) *RevocationRevokeMsg { | 95 | func NewRevocationRevokeMsg(zsig *crypto.ZoneSignature) *RevocationRevokeMsg { |
110 | return &RevocationRevokeMsg{ | 96 | return &RevocationRevokeMsg{ |
111 | MsgSize: 364, | 97 | MsgHeader: MsgHeader{364, enums.MSG_REVOCATION_REVOKE}, |
112 | MsgType: REVOCATION_REVOKE, | ||
113 | Timestamp: util.AbsoluteTimeNow(), | 98 | Timestamp: util.AbsoluteTimeNow(), |
114 | TTL: util.RelativeTime{}, | 99 | TTL: util.RelativeTime{}, |
115 | PoWs: make([]uint64, 32), | 100 | PoWs: make([]uint64, 32), |
@@ -119,12 +104,8 @@ func NewRevocationRevokeMsg(zsig *crypto.ZoneSignature) *RevocationRevokeMsg { | |||
119 | 104 | ||
120 | // String returns a human-readable representation of the message. | 105 | // String returns a human-readable representation of the message. |
121 | func (m *RevocationRevokeMsg) String() string { | 106 | func (m *RevocationRevokeMsg) String() string { |
122 | return fmt.Sprintf("RevocationRevokeMsg{zone=%s}", m.ZoneKeySig.ID()) | 107 | return fmt.Sprintf("RevocationRevokeMsg{zone=%s,expire=%s}", |
123 | } | 108 | m.ZoneKeySig.ID(), m.Timestamp.AddRelative(m.TTL)) |
124 | |||
125 | // Header returns the message header in a separate instance. | ||
126 | func (m *RevocationRevokeMsg) Header() *Header { | ||
127 | return &Header{m.MsgSize, m.MsgType} | ||
128 | } | 109 | } |
129 | 110 | ||
130 | //---------------------------------------------------------------------- | 111 | //---------------------------------------------------------------------- |
@@ -133,8 +114,7 @@ func (m *RevocationRevokeMsg) Header() *Header { | |||
133 | 114 | ||
134 | // RevocationRevokeResponseMsg is a response message for a revocation request | 115 | // RevocationRevokeResponseMsg is a response message for a revocation request |
135 | type RevocationRevokeResponseMsg struct { | 116 | type RevocationRevokeResponseMsg struct { |
136 | MsgSize uint16 `order:"big"` // total size of message | 117 | MsgHeader |
137 | MsgType uint16 `order:"big"` // REVOCATION_REVOKE_RESPONSE (639) | ||
138 | Success uint32 `order:"big"` // Revoke successful? (0=no, 1=yes) | 118 | Success uint32 `order:"big"` // Revoke successful? (0=no, 1=yes) |
139 | } | 119 | } |
140 | 120 | ||
@@ -145,9 +125,8 @@ func NewRevocationRevokeResponseMsg(success bool) *RevocationRevokeResponseMsg { | |||
145 | status = 1 | 125 | status = 1 |
146 | } | 126 | } |
147 | return &RevocationRevokeResponseMsg{ | 127 | return &RevocationRevokeResponseMsg{ |
148 | MsgSize: 8, | 128 | MsgHeader: MsgHeader{8, enums.MSG_REVOCATION_QUERY_RESPONSE}, |
149 | MsgType: REVOCATION_QUERY_RESPONSE, | 129 | Success: uint32(status), |
150 | Success: uint32(status), | ||
151 | } | 130 | } |
152 | } | 131 | } |
153 | 132 | ||
@@ -155,8 +134,3 @@ func NewRevocationRevokeResponseMsg(success bool) *RevocationRevokeResponseMsg { | |||
155 | func (m *RevocationRevokeResponseMsg) String() string { | 134 | func (m *RevocationRevokeResponseMsg) String() string { |
156 | return fmt.Sprintf("RevocationRevokeResponseMsg{success=%v}", m.Success == 1) | 135 | return fmt.Sprintf("RevocationRevokeResponseMsg{success=%v}", m.Success == 1) |
157 | } | 136 | } |
158 | |||
159 | // Header returns the message header in a separate instance. | ||
160 | func (m *RevocationRevokeResponseMsg) Header() *Header { | ||
161 | return &Header{m.MsgSize, m.MsgType} | ||
162 | } | ||
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 ( | |||
37 | 37 | ||
38 | // TransportTCPWelcomeMsg is a welcome message for new TCP connections. | 38 | // TransportTCPWelcomeMsg is a welcome message for new TCP connections. |
39 | type TransportTCPWelcomeMsg struct { | 39 | type TransportTCPWelcomeMsg struct { |
40 | MsgSize uint16 `order:"big"` // total size of message | 40 | MsgHeader |
41 | MsgType uint16 `order:"big"` // TRANSPORT_TCP_WELCOME (61) | 41 | PeerID *util.PeerID // Peer identity (EdDSA public key) |
42 | PeerID *util.PeerID // Peer identity (EdDSA public key) | ||
43 | } | 42 | } |
44 | 43 | ||
45 | // NewTransportTCPWelcomeMsg creates a new message for a given peer. | 44 | // NewTransportTCPWelcomeMsg creates a new message for a given peer. |
@@ -48,9 +47,8 @@ func NewTransportTCPWelcomeMsg(peerid *util.PeerID) *TransportTCPWelcomeMsg { | |||
48 | peerid = util.NewPeerID(nil) | 47 | peerid = util.NewPeerID(nil) |
49 | } | 48 | } |
50 | return &TransportTCPWelcomeMsg{ | 49 | return &TransportTCPWelcomeMsg{ |
51 | MsgSize: 36, | 50 | MsgHeader: MsgHeader{36, enums.MSG_TRANSPORT_TCP_WELCOME}, |
52 | MsgType: TRANSPORT_TCP_WELCOME, | 51 | PeerID: peerid, |
53 | PeerID: peerid, | ||
54 | } | 52 | } |
55 | } | 53 | } |
56 | 54 | ||
@@ -59,11 +57,6 @@ func (m *TransportTCPWelcomeMsg) String() string { | |||
59 | return fmt.Sprintf("TransportTcpWelcomeMsg{peer=%s}", m.PeerID) | 57 | return fmt.Sprintf("TransportTcpWelcomeMsg{peer=%s}", m.PeerID) |
60 | } | 58 | } |
61 | 59 | ||
62 | // Header returns the message header in a separate instance. | ||
63 | func (m *TransportTCPWelcomeMsg) Header() *Header { | ||
64 | return &Header{m.MsgSize, m.MsgType} | ||
65 | } | ||
66 | |||
67 | //---------------------------------------------------------------------- | 60 | //---------------------------------------------------------------------- |
68 | // TRANSPORT_PING | 61 | // TRANSPORT_PING |
69 | // | 62 | // |
@@ -75,8 +68,7 @@ func (m *TransportTCPWelcomeMsg) Header() *Header { | |||
75 | 68 | ||
76 | // TransportPingMsg is a PING request message | 69 | // TransportPingMsg is a PING request message |
77 | type TransportPingMsg struct { | 70 | type TransportPingMsg struct { |
78 | MsgSize uint16 `order:"big"` // total size of message | 71 | MsgHeader |
79 | MsgType uint16 `order:"big"` // TRANSPORT_PING (372) | ||
80 | Challenge uint32 // Challenge code (to ensure fresh reply) | 72 | Challenge uint32 // Challenge code (to ensure fresh reply) |
81 | Target *util.PeerID // EdDSA public key (long-term) of target peer | 73 | Target *util.PeerID // EdDSA public key (long-term) of target peer |
82 | Address []byte `size:"*"` // encoded address | 74 | Address []byte `size:"*"` // encoded address |
@@ -89,8 +81,7 @@ func NewTransportPingMsg(target *util.PeerID, a *util.Address) *TransportPingMsg | |||
89 | target = util.NewPeerID(nil) | 81 | target = util.NewPeerID(nil) |
90 | } | 82 | } |
91 | m := &TransportPingMsg{ | 83 | m := &TransportPingMsg{ |
92 | MsgSize: uint16(40), | 84 | MsgHeader: MsgHeader{40, enums.MSG_TRANSPORT_PING}, |
93 | MsgType: TRANSPORT_PING, | ||
94 | Challenge: util.RndUInt32(), | 85 | Challenge: util.RndUInt32(), |
95 | Target: target, | 86 | Target: target, |
96 | Address: nil, | 87 | Address: nil, |
@@ -114,11 +105,6 @@ func (m *TransportPingMsg) String() string { | |||
114 | m.Target, a, m.Challenge) | 105 | m.Target, a, m.Challenge) |
115 | } | 106 | } |
116 | 107 | ||
117 | // Header returns the message header in a separate instance. | ||
118 | func (m *TransportPingMsg) Header() *Header { | ||
119 | return &Header{m.MsgSize, m.MsgType} | ||
120 | } | ||
121 | |||
122 | //---------------------------------------------------------------------- | 108 | //---------------------------------------------------------------------- |
123 | // TRANSPORT_PONG | 109 | // TRANSPORT_PONG |
124 | // | 110 | // |
@@ -160,8 +146,7 @@ func NewSignedAddress(a *util.Address) *SignedAddress { | |||
160 | 146 | ||
161 | // TransportPongMsg is a response message for a PING request | 147 | // TransportPongMsg is a response message for a PING request |
162 | type TransportPongMsg struct { | 148 | type TransportPongMsg struct { |
163 | MsgSize uint16 `order:"big"` // total size of message | 149 | MsgHeader |
164 | MsgType uint16 `order:"big"` // TRANSPORT_PING (372) | ||
165 | Challenge uint32 // Challenge code (to ensure fresh reply) | 150 | Challenge uint32 // Challenge code (to ensure fresh reply) |
166 | Signature []byte `size:"64"` // Signature of address | 151 | Signature []byte `size:"64"` // Signature of address |
167 | SignedBlock *SignedAddress // signed block of data | 152 | SignedBlock *SignedAddress // signed block of data |
@@ -171,8 +156,7 @@ type TransportPongMsg struct { | |||
171 | // peer wants to be reached. | 156 | // peer wants to be reached. |
172 | func NewTransportPongMsg(challenge uint32, a *util.Address) *TransportPongMsg { | 157 | func NewTransportPongMsg(challenge uint32, a *util.Address) *TransportPongMsg { |
173 | m := &TransportPongMsg{ | 158 | m := &TransportPongMsg{ |
174 | MsgSize: 72, | 159 | MsgHeader: MsgHeader{72, enums.MSG_TRANSPORT_PONG}, |
175 | MsgType: TRANSPORT_PONG, | ||
176 | Challenge: challenge, | 160 | Challenge: challenge, |
177 | Signature: make([]byte, 64), | 161 | Signature: make([]byte, 64), |
178 | SignedBlock: new(SignedAddress), | 162 | SignedBlock: new(SignedAddress), |
@@ -195,11 +179,6 @@ func (m *TransportPongMsg) String() string { | |||
195 | return fmt.Sprintf("TransportPongMsg{addr=<unknown>,%d}", m.Challenge) | 179 | return fmt.Sprintf("TransportPongMsg{addr=<unknown>,%d}", m.Challenge) |
196 | } | 180 | } |
197 | 181 | ||
198 | // Header returns the message header in a separate instance. | ||
199 | func (m *TransportPongMsg) Header() *Header { | ||
200 | return &Header{m.MsgSize, m.MsgType} | ||
201 | } | ||
202 | |||
203 | // Sign the address block of a pong message. | 182 | // Sign the address block of a pong message. |
204 | func (m *TransportPongMsg) Sign(prv *ed25519.PrivateKey) error { | 183 | func (m *TransportPongMsg) Sign(prv *ed25519.PrivateKey) error { |
205 | data, err := data.Marshal(m.SignedBlock) | 184 | data, err := data.Marshal(m.SignedBlock) |
@@ -233,15 +212,13 @@ func (m *TransportPongMsg) Verify(pub *ed25519.PublicKey) (bool, error) { | |||
233 | 212 | ||
234 | // SessionAckMsg is a message to acknowledge a session request | 213 | // SessionAckMsg is a message to acknowledge a session request |
235 | type SessionAckMsg struct { | 214 | type SessionAckMsg struct { |
236 | MsgSize uint16 `order:"big"` // total size of message | 215 | MsgHeader |
237 | MsgType uint16 `order:"big"` // TRANSPORT_SESSION_ACK (377) | ||
238 | } | 216 | } |
239 | 217 | ||
240 | // NewSessionAckMsg creates an new message (no body required). | 218 | // NewSessionAckMsg creates an new message (no body required). |
241 | func NewSessionAckMsg() *SessionAckMsg { | 219 | func NewSessionAckMsg() *SessionAckMsg { |
242 | return &SessionAckMsg{ | 220 | return &SessionAckMsg{ |
243 | MsgSize: 16, | 221 | MsgHeader: MsgHeader{4, enums.MSG_TRANSPORT_SESSION_ACK}, |
244 | MsgType: TRANSPORT_SESSION_ACK, | ||
245 | } | 222 | } |
246 | } | 223 | } |
247 | 224 | ||
@@ -250,19 +227,13 @@ func (m *SessionAckMsg) String() string { | |||
250 | return "SessionAck{}" | 227 | return "SessionAck{}" |
251 | } | 228 | } |
252 | 229 | ||
253 | // Header returns the message header in a separate instance. | ||
254 | func (m *SessionAckMsg) Header() *Header { | ||
255 | return &Header{m.MsgSize, m.MsgType} | ||
256 | } | ||
257 | |||
258 | //---------------------------------------------------------------------- | 230 | //---------------------------------------------------------------------- |
259 | // TRANSPORT_SESSION_SYN | 231 | // TRANSPORT_SESSION_SYN |
260 | //---------------------------------------------------------------------- | 232 | //---------------------------------------------------------------------- |
261 | 233 | ||
262 | // SessionSynMsg is a synchronization request message for sessions | 234 | // SessionSynMsg is a synchronization request message for sessions |
263 | type SessionSynMsg struct { | 235 | type SessionSynMsg struct { |
264 | MsgSize uint16 `order:"big"` // total size of message | 236 | MsgHeader |
265 | MsgType uint16 `order:"big"` // TRANSPORT_SESSION_SYN (375) | ||
266 | Reserved uint32 `order:"big"` // reserved (=0) | 237 | Reserved uint32 `order:"big"` // reserved (=0) |
267 | Timestamp util.AbsoluteTime // usec epoch | 238 | Timestamp util.AbsoluteTime // usec epoch |
268 | } | 239 | } |
@@ -270,8 +241,7 @@ type SessionSynMsg struct { | |||
270 | // NewSessionSynMsg creates a SYN request for the a session | 241 | // NewSessionSynMsg creates a SYN request for the a session |
271 | func NewSessionSynMsg() *SessionSynMsg { | 242 | func NewSessionSynMsg() *SessionSynMsg { |
272 | return &SessionSynMsg{ | 243 | return &SessionSynMsg{ |
273 | MsgSize: 16, | 244 | MsgHeader: MsgHeader{16, enums.MSG_TRANSPORT_SESSION_SYN}, |
274 | MsgType: TRANSPORT_SESSION_SYN, | ||
275 | Reserved: 0, | 245 | Reserved: 0, |
276 | Timestamp: util.AbsoluteTimeNow(), | 246 | Timestamp: util.AbsoluteTimeNow(), |
277 | } | 247 | } |
@@ -282,19 +252,13 @@ func (m *SessionSynMsg) String() string { | |||
282 | return fmt.Sprintf("SessionSyn{timestamp=%s}", m.Timestamp) | 252 | return fmt.Sprintf("SessionSyn{timestamp=%s}", m.Timestamp) |
283 | } | 253 | } |
284 | 254 | ||
285 | // Header returns the message header in a separate instance. | ||
286 | func (m *SessionSynMsg) Header() *Header { | ||
287 | return &Header{m.MsgSize, m.MsgType} | ||
288 | } | ||
289 | |||
290 | //---------------------------------------------------------------------- | 255 | //---------------------------------------------------------------------- |
291 | // TRANSPORT_SESSION_SYN_ACK | 256 | // TRANSPORT_SESSION_SYN_ACK |
292 | //---------------------------------------------------------------------- | 257 | //---------------------------------------------------------------------- |
293 | 258 | ||
294 | // SessionSynAckMsg responds to a SYN request message | 259 | // SessionSynAckMsg responds to a SYN request message |
295 | type SessionSynAckMsg struct { | 260 | type SessionSynAckMsg struct { |
296 | MsgSize uint16 `order:"big"` // total size of message | 261 | MsgHeader |
297 | MsgType uint16 `order:"big"` // TRANSPORT_SESSION_SYN_ACK (376) | ||
298 | Reserved uint32 `order:"big"` // reserved (=0) | 262 | Reserved uint32 `order:"big"` // reserved (=0) |
299 | Timestamp util.AbsoluteTime // usec epoch | 263 | Timestamp util.AbsoluteTime // usec epoch |
300 | } | 264 | } |
@@ -302,8 +266,7 @@ type SessionSynAckMsg struct { | |||
302 | // NewSessionSynAckMsg is an ACK for a SYN request | 266 | // NewSessionSynAckMsg is an ACK for a SYN request |
303 | func NewSessionSynAckMsg() *SessionSynAckMsg { | 267 | func NewSessionSynAckMsg() *SessionSynAckMsg { |
304 | return &SessionSynAckMsg{ | 268 | return &SessionSynAckMsg{ |
305 | MsgSize: 16, | 269 | MsgHeader: MsgHeader{16, enums.MSG_TRANSPORT_SESSION_SYN_ACK}, |
306 | MsgType: TRANSPORT_SESSION_SYN_ACK, | ||
307 | Reserved: 0, | 270 | Reserved: 0, |
308 | Timestamp: util.AbsoluteTimeNow(), | 271 | Timestamp: util.AbsoluteTimeNow(), |
309 | } | 272 | } |
@@ -314,28 +277,22 @@ func (m *SessionSynAckMsg) String() string { | |||
314 | return fmt.Sprintf("SessionSynAck{timestamp=%s}", m.Timestamp) | 277 | return fmt.Sprintf("SessionSynAck{timestamp=%s}", m.Timestamp) |
315 | } | 278 | } |
316 | 279 | ||
317 | // Header returns the message header in a separate instance. | ||
318 | func (m *SessionSynAckMsg) Header() *Header { | ||
319 | return &Header{m.MsgSize, m.MsgType} | ||
320 | } | ||
321 | |||
322 | //---------------------------------------------------------------------- | 280 | //---------------------------------------------------------------------- |
323 | // TRANSPORT_SESSION_QUOTA | 281 | // TRANSPORT_SESSION_QUOTA |
324 | //---------------------------------------------------------------------- | 282 | //---------------------------------------------------------------------- |
325 | 283 | ||
326 | // SessionQuotaMsg is a message to announce quotas for a session | 284 | // SessionQuotaMsg is a message to announce quotas for a session |
327 | type SessionQuotaMsg struct { | 285 | type SessionQuotaMsg struct { |
328 | MsgSize uint16 `order:"big"` // total size of message | 286 | MsgHeader |
329 | MsgType uint16 `order:"big"` // TRANSPORT_SESSION_QUOTA (379) | 287 | Quota uint32 `order:"big"` // Quota in bytes per second |
330 | Quota uint32 `order:"big"` // Quota in bytes per second | ||
331 | } | 288 | } |
332 | 289 | ||
333 | // NewSessionQuotaMsg announces a session quota to the other end of the session. | 290 | // NewSessionQuotaMsg announces a session quota to the other end of the session. |
334 | func NewSessionQuotaMsg(quota uint32) *SessionQuotaMsg { | 291 | func NewSessionQuotaMsg(quota uint32) *SessionQuotaMsg { |
335 | m := new(SessionQuotaMsg) | 292 | m := new(SessionQuotaMsg) |
293 | m.MsgSize = 8 | ||
294 | m.MsgType = enums.MSG_TRANSPORT_SESSION_QUOTA | ||
336 | if quota > 0 { | 295 | if quota > 0 { |
337 | m.MsgSize = 8 | ||
338 | m.MsgType = TRANSPORT_SESSION_QUOTA | ||
339 | m.Quota = quota | 296 | m.Quota = quota |
340 | } | 297 | } |
341 | return m | 298 | return m |
@@ -346,28 +303,21 @@ func (m *SessionQuotaMsg) String() string { | |||
346 | return fmt.Sprintf("SessionQuotaMsg{%sB/s}", util.Scale1024(uint64(m.Quota))) | 303 | return fmt.Sprintf("SessionQuotaMsg{%sB/s}", util.Scale1024(uint64(m.Quota))) |
347 | } | 304 | } |
348 | 305 | ||
349 | // Header returns the message header in a separate instance. | ||
350 | func (m *SessionQuotaMsg) Header() *Header { | ||
351 | return &Header{m.MsgSize, m.MsgType} | ||
352 | } | ||
353 | |||
354 | //---------------------------------------------------------------------- | 306 | //---------------------------------------------------------------------- |
355 | // TRANSPORT_SESSION_KEEPALIVE | 307 | // TRANSPORT_SESSION_KEEPALIVE |
356 | //---------------------------------------------------------------------- | 308 | //---------------------------------------------------------------------- |
357 | 309 | ||
358 | // SessionKeepAliveMsg is a message send by peers to keep a session alive. | 310 | // SessionKeepAliveMsg is a message send by peers to keep a session alive. |
359 | type SessionKeepAliveMsg struct { | 311 | type SessionKeepAliveMsg struct { |
360 | MsgSize uint16 `order:"big"` // total size of message | 312 | MsgHeader |
361 | MsgType uint16 `order:"big"` // TRANSPORT_SESSION_KEEPALIVE (381) | 313 | Nonce uint32 |
362 | Nonce uint32 | ||
363 | } | 314 | } |
364 | 315 | ||
365 | // NewSessionKeepAliveMsg creates a new request to keep a session. | 316 | // NewSessionKeepAliveMsg creates a new request to keep a session. |
366 | func NewSessionKeepAliveMsg() *SessionKeepAliveMsg { | 317 | func NewSessionKeepAliveMsg() *SessionKeepAliveMsg { |
367 | m := &SessionKeepAliveMsg{ | 318 | m := &SessionKeepAliveMsg{ |
368 | MsgSize: 8, | 319 | MsgHeader: MsgHeader{8, enums.MSG_TRANSPORT_SESSION_KEEPALIVE}, |
369 | MsgType: TRANSPORT_SESSION_KEEPALIVE, | 320 | Nonce: util.RndUInt32(), |
370 | Nonce: util.RndUInt32(), | ||
371 | } | 321 | } |
372 | return m | 322 | return m |
373 | } | 323 | } |
@@ -377,28 +327,21 @@ func (m *SessionKeepAliveMsg) String() string { | |||
377 | return fmt.Sprintf("SessionKeepAliveMsg{%d}", m.Nonce) | 327 | return fmt.Sprintf("SessionKeepAliveMsg{%d}", m.Nonce) |
378 | } | 328 | } |
379 | 329 | ||
380 | // Header returns the message header in a separate instance. | ||
381 | func (m *SessionKeepAliveMsg) Header() *Header { | ||
382 | return &Header{m.MsgSize, m.MsgType} | ||
383 | } | ||
384 | |||
385 | //---------------------------------------------------------------------- | 330 | //---------------------------------------------------------------------- |
386 | // TRANSPORT_SESSION_KEEPALIVE_RESPONSE | 331 | // TRANSPORT_SESSION_KEEPALIVE_RESPONSE |
387 | //---------------------------------------------------------------------- | 332 | //---------------------------------------------------------------------- |
388 | 333 | ||
389 | // SessionKeepAliveRespMsg is a response for a peer to a "keep-alive" request. | 334 | // SessionKeepAliveRespMsg is a response for a peer to a "keep-alive" request. |
390 | type SessionKeepAliveRespMsg struct { | 335 | type SessionKeepAliveRespMsg struct { |
391 | MsgSize uint16 `order:"big"` // total size of message | 336 | MsgHeader |
392 | MsgType uint16 `order:"big"` // TRANSPORT_SESSION_KEEPALIVE_RESPONSE (382) | 337 | Nonce uint32 |
393 | Nonce uint32 | ||
394 | } | 338 | } |
395 | 339 | ||
396 | // NewSessionKeepAliveRespMsg is a response message for a "keep session" request. | 340 | // NewSessionKeepAliveRespMsg is a response message for a "keep session" request. |
397 | func NewSessionKeepAliveRespMsg(nonce uint32) *SessionKeepAliveRespMsg { | 341 | func NewSessionKeepAliveRespMsg(nonce uint32) *SessionKeepAliveRespMsg { |
398 | m := &SessionKeepAliveRespMsg{ | 342 | m := &SessionKeepAliveRespMsg{ |
399 | MsgSize: 8, | 343 | MsgHeader: MsgHeader{8, enums.MSG_TRANSPORT_SESSION_KEEPALIVE_RESPONSE}, |
400 | MsgType: TRANSPORT_SESSION_KEEPALIVE_RESPONSE, | 344 | Nonce: nonce, |
401 | Nonce: nonce, | ||
402 | } | 345 | } |
403 | return m | 346 | return m |
404 | } | 347 | } |
@@ -407,8 +350,3 @@ func NewSessionKeepAliveRespMsg(nonce uint32) *SessionKeepAliveRespMsg { | |||
407 | func (m *SessionKeepAliveRespMsg) String() string { | 350 | func (m *SessionKeepAliveRespMsg) String() string { |
408 | return fmt.Sprintf("SessionKeepAliveRespMsg{%d}", m.Nonce) | 351 | return fmt.Sprintf("SessionKeepAliveRespMsg{%d}", m.Nonce) |
409 | } | 352 | } |
410 | |||
411 | // Header returns the message header in a separate instance. | ||
412 | func (m *SessionKeepAliveRespMsg) Header() *Header { | ||
413 | return &Header{m.MsgSize, m.MsgType} | ||
414 | } | ||
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 @@ | |||
1 | // This file is part of gnunet-go, a GNUnet-implementation in Golang. | ||
2 | // Copyright (C) 2019-2022 Bernd Fix >Y< | ||
3 | // | ||
4 | // gnunet-go is free software: you can redistribute it and/or modify it | ||
5 | // under the terms of the GNU Affero General Public License as published | ||
6 | // by the Free Software Foundation, either version 3 of the License, | ||
7 | // or (at your option) any later version. | ||
8 | // | ||
9 | // gnunet-go is distributed in the hope that it will be useful, but | ||
10 | // WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | // Affero General Public License for more details. | ||
13 | // | ||
14 | // You should have received a copy of the GNU Affero General Public License | ||
15 | // along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | // | ||
17 | // SPDX-License-Identifier: AGPL3.0-or-later | ||
18 | |||
19 | //nolint:stylecheck // allow non-camel-case in constants | ||
20 | package message | ||
21 | |||
22 | // GNUnet message types | ||
23 | const ( | ||
24 | TEST = 1 // Test if service is online (deprecated) | ||
25 | DUMMY = 2 // Dummy messages for testing / benchmarking | ||
26 | DUMMY2 = 3 // Another dummy messages for testing / benchmarking | ||
27 | |||
28 | //------------------------------------------------------------------ | ||
29 | // RESOLVER message types | ||
30 | //------------------------------------------------------------------ | ||
31 | |||
32 | RESOLVER_REQUEST = 4 // Request DNS resolution | ||
33 | RESOLVER_RESPONSE = 5 // Response to a DNS resolution request | ||
34 | |||
35 | //------------------------------------------------------------------ | ||
36 | // AGPL source code download | ||
37 | //------------------------------------------------------------------ | ||
38 | |||
39 | REQUEST_AGPL = 6 // Message to request source code link | ||
40 | RESPONSE_AGPL = 7 // Source code link | ||
41 | |||
42 | //------------------------------------------------------------------ | ||
43 | // ARM message types | ||
44 | //------------------------------------------------------------------ | ||
45 | |||
46 | ARM_START = 8 // Request to ARM to start a service | ||
47 | ARM_STOP = 9 // Request to ARM to stop a service | ||
48 | ARM_RESULT = 10 // Response from ARM | ||
49 | ARM_STATUS = 11 // Status update from ARM | ||
50 | ARM_LIST = 12 // Request to ARM to list all currently running services | ||
51 | ARM_LIST_RESULT = 13 // Response from ARM for listing currently running services | ||
52 | ARM_MONITOR = 14 // Request to ARM to notify client of service status changes | ||
53 | ARM_TEST = 15 // Test if ARM service is online | ||
54 | |||
55 | //------------------------------------------------------------------ | ||
56 | // HELLO message types | ||
57 | //------------------------------------------------------------------ | ||
58 | |||
59 | HELLO_LEGACY = 16 // Deprecated HELLO message | ||
60 | HELLO = 17 // HELLO message with friend_only flag | ||
61 | |||
62 | //------------------------------------------------------------------ | ||
63 | // FRAGMENTATION message types | ||
64 | //------------------------------------------------------------------ | ||
65 | |||
66 | FRAGMENT = 18 // FRAGMENT of a larger message | ||
67 | FRAGMENT_ACK = 19 // Acknowledgement of a FRAGMENT of a larger message | ||
68 | |||
69 | //------------------------------------------------------------------ | ||
70 | // Transport-WLAN message types | ||
71 | //------------------------------------------------------------------ | ||
72 | |||
73 | WLAN_DATA_TO_HELPER = 39 // Type of data messages from the plugin to the gnunet-wlan-helper | ||
74 | WLAN_DATA_FROM_HELPER = 40 // Type of data messages from the gnunet-wlan-helper to the plugin | ||
75 | WLAN_HELPER_CONTROL = 41 // Control message between the gnunet-wlan-helper and the daemon (with the MAC) | ||
76 | WLAN_ADVERTISEMENT = 42 // Type of messages for advertisement over wlan | ||
77 | WLAN_DATA = 43 // Type of messages for data over the wlan | ||
78 | |||
79 | //------------------------------------------------------------------ | ||
80 | // Transport-DV message types | ||
81 | //------------------------------------------------------------------ | ||
82 | |||
83 | DV_RECV = 44 // DV service to DV Plugin message | ||
84 | DV_SEND = 45 // DV Plugin to DV service message | ||
85 | DV_SEND_ACK = 46 // Confirmation or failure of a DV_SEND message | ||
86 | DV_ROUTE = 47 // P2P DV message encapsulating some real message | ||
87 | DV_START = 48 // DV Plugin to DV service message, indicating startup. | ||
88 | DV_CONNECT = 49 // P2P DV message telling plugin that a peer connected | ||
89 | DV_DISCONNECT = 50 // P2P DV message telling plugin that a peer disconnected | ||
90 | DV_SEND_NACK = 51 // P2P DV message telling plugin that a message transmission failed (negative ACK) | ||
91 | DV_DISTANCE_CHANGED = 52 // P2P DV message telling plugin that our distance to a peer changed | ||
92 | DV_BOX = 53 // DV message box for boxing multiple messages. | ||
93 | TRANSPORT_XU_MESSAGE = 55 // Experimental message type. | ||
94 | |||
95 | //------------------------------------------------------------------ | ||
96 | // Transport-UDP message types | ||
97 | //------------------------------------------------------------------ | ||
98 | |||
99 | TRANSPORT_UDP_MESSAGE = 56 // Normal UDP message type. | ||
100 | TRANSPORT_UDP_ACK = 57 // UDP ACK. | ||
101 | |||
102 | //------------------------------------------------------------------ | ||
103 | // Transport-TCP message types | ||
104 | //------------------------------------------------------------------ | ||
105 | |||
106 | TRANSPORT_TCP_NAT_PROBE = 60 // TCP NAT probe message | ||
107 | TRANSPORT_TCP_WELCOME = 61 // Welcome message between TCP transports. | ||
108 | TRANSPORT_ATS = 62 // Message to force transport to update bandwidth assignment (LEGACY) | ||
109 | |||
110 | //------------------------------------------------------------------ | ||
111 | // NAT message types | ||
112 | //------------------------------------------------------------------ | ||
113 | |||
114 | NAT_TEST = 63 // Message to ask NAT server to perform traversal test | ||
115 | |||
116 | //------------------------------------------------------------------ | ||
117 | // CORE message types | ||
118 | //------------------------------------------------------------------ | ||
119 | |||
120 | CORE_INIT = 64 // Initial setup message from core client to core. | ||
121 | CORE_INIT_REPLY = 65 // Response from core to core client to INIT message. | ||
122 | CORE_NOTIFY_CONNECT = 67 // Notify clients about new peer-to-peer connections (triggered after key exchange). | ||
123 | CORE_NOTIFY_DISCONNECT = 68 // Notify clients about peer disconnecting. | ||
124 | CORE_NOTIFY_STATUS_CHANGE = 69 // Notify clients about peer status change. | ||
125 | CORE_NOTIFY_INBOUND = 70 // Notify clients about incoming P2P messages. | ||
126 | CORE_NOTIFY_OUTBOUND = 71 // Notify clients about outgoing P2P transmissions. | ||
127 | CORE_SEND_REQUEST = 74 // Request from client to transmit message. | ||
128 | CORE_SEND_READY = 75 // Confirmation from core that message can now be sent | ||
129 | CORE_SEND = 76 // Client with message to transmit (after SEND_READY confirmation was received). | ||
130 | CORE_MONITOR_PEERS = 78 // Request for connection monitoring from CORE service. | ||
131 | CORE_MONITOR_NOTIFY = 79 // Reply for monitor by CORE service. | ||
132 | CORE_ENCRYPTED_MESSAGE = 82 // Encapsulation for an encrypted message between peers. | ||
133 | CORE_PING = 83 // Check that other peer is alive (challenge). | ||
134 | CORE_PONG = 84 // Confirmation that other peer is alive. | ||
135 | CORE_HANGUP = 85 // Request by the other peer to terminate the connection. | ||
136 | CORE_COMPRESSED_TYPE_MAP = 86 // gzip-compressed type map of the sender | ||
137 | CORE_BINARY_TYPE_MAP = 87 // uncompressed type map of the sender | ||
138 | CORE_EPHEMERAL_KEY = 88 // Session key exchange between peers. | ||
139 | CORE_CONFIRM_TYPE_MAP = 89 // Other peer confirms having received the type map | ||
140 | |||
141 | //------------------------------------------------------------------ | ||
142 | // DATASTORE message types | ||
143 | //------------------------------------------------------------------ | ||
144 | |||
145 | DATASTORE_RESERVE = 92 // Message sent by datastore client on join. | ||
146 | DATASTORE_RELEASE_RESERVE = 93 // Message sent by datastore client on join. | ||
147 | 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). | ||
148 | DATASTORE_PUT = 95 // Message sent by datastore client to store data. | ||
149 | DATASTORE_GET = 97 // Message sent by datastore client to get data. | ||
150 | DATASTORE_GET_REPLICATION = 98 // Message sent by datastore client to get random data. | ||
151 | DATASTORE_GET_ZERO_ANONYMITY = 99 // Message sent by datastore client to get random data. | ||
152 | DATASTORE_DATA = 100 // Message sent by datastore to client providing requested data (in response to GET or GET_RANDOM request). | ||
153 | 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. | ||
154 | DATASTORE_REMOVE = 102 // Message sent by datastore client to remove data. | ||
155 | DATASTORE_DROP = 103 // Message sent by datastore client to drop the database. | ||
156 | DATASTORE_GET_KEY = 104 // Message sent by datastore client to get data by key. | ||
157 | |||
158 | //------------------------------------------------------------------ | ||
159 | // FS message types | ||
160 | //------------------------------------------------------------------ | ||
161 | |||
162 | FS_REQUEST_LOC_SIGN = 126 // Message sent by fs client to request LOC signature. | ||
163 | FS_REQUEST_LOC_SIGNATURE = 127 // Reply sent by fs service with LOC signature. | ||
164 | FS_INDEX_START = 128 // Message sent by fs client to start indexing. | ||
165 | FS_INDEX_START_OK = 129 // Affirmative response to a request for start indexing. | ||
166 | FS_INDEX_START_FAILED = 130 // Response to a request for start indexing that refuses. | ||
167 | FS_INDEX_LIST_GET = 131 // Request from client for list of indexed files. | ||
168 | FS_INDEX_LIST_ENTRY = 132 // Reply to client with an indexed file name. | ||
169 | FS_INDEX_LIST_END = 133 // Reply to client indicating end of list. | ||
170 | FS_UNINDEX = 134 // Request from client to unindex a file. | ||
171 | FS_UNINDEX_OK = 135 // Reply to client indicating unindex receipt. | ||
172 | FS_START_SEARCH = 136 // Client asks FS service to start a (keyword) search. | ||
173 | FS_GET = 137 // P2P request for content (one FS to another). | ||
174 | 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). | ||
175 | FS_MIGRATION_STOP = 139 // Peer asks us to stop migrating content towards it for a while. | ||
176 | FS_CADET_QUERY = 140 // P2P request for content (one FS to another via a cadet). | ||
177 | FS_CADET_REPLY = 141 // P2P answer for content (one FS to another via a cadet). | ||
178 | |||
179 | //------------------------------------------------------------------ | ||
180 | // DHT message types | ||
181 | //------------------------------------------------------------------ | ||
182 | |||
183 | DHT_CLIENT_PUT = 142 // Client wants to store item in DHT. | ||
184 | DHT_CLIENT_GET = 143 // Client wants to lookup item in DHT. | ||
185 | DHT_CLIENT_GET_STOP = 144 // Client wants to stop search in DHT. | ||
186 | DHT_CLIENT_RESULT = 145 // Service returns result to client. | ||
187 | DHT_P2P_PUT = 146 // Peer is storing data in DHT. | ||
188 | DHT_P2P_GET = 147 // Peer tries to find data in DHT. | ||
189 | DHT_P2P_RESULT = 148 // Data is returned to peer from DHT. | ||
190 | DHT_MONITOR_GET = 149 // Receive information about transiting GETs | ||
191 | DHT_MONITOR_GET_RESP = 150 // Receive information about transiting GET responses | ||
192 | DHT_MONITOR_PUT = 151 // Receive information about transiting PUTs | ||
193 | DHT_MONITOR_PUT_RESP = 152 // Receive information about transiting PUT responses (TODO) | ||
194 | DHT_MONITOR_START = 153 // Request information about transiting messages | ||
195 | DHT_MONITOR_STOP = 154 // Stop information about transiting messages | ||
196 | DHT_CLIENT_GET_RESULTS_KNOWN = 156 // Certain results are already known to the client, filter those. | ||
197 | DHT_P2P_HELLO = 157 // HELLO advertising a neighbours addresses. | ||
198 | DHT_CORE = 158 // Encapsulation of DHT messages in CORE service. | ||
199 | DHT_CLIENT_HELLO_URL = 159 // HELLO URL send between client and service (in either direction). | ||
200 | DHT_CLIENT_HELLO_GET = 161 // Client requests DHT service's HELLO URL. | ||
201 | |||
202 | //------------------------------------------------------------------ | ||
203 | // HOSTLIST message types | ||
204 | //------------------------------------------------------------------ | ||
205 | |||
206 | HOSTLIST_ADVERTISEMENT = 160 // Hostlist advertisement message | ||
207 | |||
208 | //------------------------------------------------------------------ | ||
209 | // STATISTICS message types | ||
210 | //------------------------------------------------------------------ | ||
211 | |||
212 | STATISTICS_SET = 168 // Set a statistical value. | ||
213 | STATISTICS_GET = 169 // Get a statistical value(s). | ||
214 | STATISTICS_VALUE = 170 // Response to a STATISTICS_GET message (with value). | ||
215 | STATISTICS_END = 171 // Response to a STATISTICS_GET message (end of value stream). | ||
216 | 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. | ||
217 | STATISTICS_WATCH_VALUE = 173 // Changes to a watched value. | ||
218 | STATISTICS_DISCONNECT = 174 // Client is done sending service requests and will now disconnect. | ||
219 | STATISTICS_DISCONNECT_CONFIRM = 175 // Service confirms disconnect and that it is done processing all requests from the client. | ||
220 | |||
221 | //------------------------------------------------------------------ | ||
222 | // VPN message types | ||
223 | //------------------------------------------------------------------ | ||
224 | |||
225 | VPN_HELPER = 185 // Type of messages between the gnunet-vpn-helper and the daemon | ||
226 | VPN_ICMP_TO_SERVICE = 190 // ICMP packet for a service. | ||
227 | VPN_ICMP_TO_INTERNET = 191 // ICMP packet for the Internet. | ||
228 | VPN_ICMP_TO_VPN = 192 // ICMP packet for the VPN | ||
229 | VPN_DNS_TO_INTERNET = 193 // DNS request for a DNS exit service. | ||
230 | VPN_DNS_FROM_INTERNET = 194 // DNS reply from a DNS exit service. | ||
231 | VPN_TCP_TO_SERVICE_START = 195 // TCP packet for a service. | ||
232 | VPN_TCP_TO_INTERNET_START = 196 // TCP packet for the Internet. | ||
233 | VPN_TCP_DATA_TO_EXIT = 197 // TCP packet of an established connection. | ||
234 | VPN_TCP_DATA_TO_VPN = 198 // TCP packet of an established connection. | ||
235 | VPN_UDP_TO_SERVICE = 199 // UDP packet for a service. | ||
236 | VPN_UDP_TO_INTERNET = 200 // UDP packet for the Internet. | ||
237 | VPN_UDP_REPLY = 201 // UDP packet from a remote host | ||
238 | 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. | ||
239 | VPN_CLIENT_REDIRECT_TO_SERVICE = 203 // Client asks VPN service to setup an IP to redirect traffic to some peer offering a service. | ||
240 | VPN_CLIENT_USE_IP = 204 // VPN service responds to client with an IP to use for the requested redirection. | ||
241 | |||
242 | //------------------------------------------------------------------ | ||
243 | // VPN-DNS message types | ||
244 | //------------------------------------------------------------------ | ||
245 | |||
246 | DNS_CLIENT_INIT = 211 // Initial message from client to DNS service for registration. | ||
247 | DNS_CLIENT_REQUEST = 212 // Type of messages between the gnunet-helper-dns and the service | ||
248 | DNS_CLIENT_RESPONSE = 213 // Type of messages between the gnunet-helper-dns and the service | ||
249 | DNS_HELPER = 214 // Type of messages between the gnunet-helper-dns and the service | ||
250 | |||
251 | //------------------------------------------------------------------ | ||
252 | // CHAT message types START | ||
253 | //------------------------------------------------------------------ | ||
254 | |||
255 | CHAT_JOIN_REQUEST = 300 // Message sent from client to join a chat room. | ||
256 | CHAT_JOIN_NOTIFICATION = 301 // Message sent to client to indicate joining of another room member. | ||
257 | CHAT_LEAVE_NOTIFICATION = 302 // Message sent to client to indicate leaving of another room member. | ||
258 | CHAT_MESSAGE_NOTIFICATION = 303 // Notification sent by service to client indicating that we've received a chat message. | ||
259 | CHAT_TRANSMIT_REQUEST = 304 // Request sent by client to transmit a chat message to another room members. | ||
260 | CHAT_CONFIRMATION_RECEIPT = 305 // Receipt sent from a message receiver to the service to confirm delivery of a chat message. | ||
261 | CHAT_CONFIRMATION_NOTIFICATION = 306 // Notification sent from the service to the original sender to acknowledge delivery of a chat message. | ||
262 | CHAT_P2P_JOIN_NOTIFICATION = 307 // P2P message sent to indicate joining of another room member. | ||
263 | CHAT_P2P_LEAVE_NOTIFICATION = 308 // P2P message sent to indicate leaving of another room member. | ||
264 | CHAT_P2P_SYNC_REQUEST = 309 // P2P message sent to a newly connected peer to request its known clients in order to synchronize room members. | ||
265 | CHAT_P2P_MESSAGE_NOTIFICATION = 310 // Notification sent from one peer to another to indicate that we have received a chat message. | ||
266 | CHAT_P2P_CONFIRMATION_RECEIPT = 311 // P2P receipt confirming delivery of a chat message. | ||
267 | |||
268 | //------------------------------------------------------------------ | ||
269 | // NSE (network size estimation) message types | ||
270 | //------------------------------------------------------------------ | ||
271 | |||
272 | NSE_START = 321 // client->service message indicating start | ||
273 | NSE_P2P_FLOOD = 322 // P2P message sent from nearest peer | ||
274 | NSE_ESTIMATE = 323 // service->client message indicating | ||
275 | |||
276 | //------------------------------------------------------------------ | ||
277 | // PEERINFO message types | ||
278 | //------------------------------------------------------------------ | ||
279 | |||
280 | PEERINFO_GET = 330 // Request update and listing of a peer | ||
281 | PEERINFO_GET_ALL = 331 // Request update and listing of all peers | ||
282 | PEERINFO_INFO = 332 // Information about one of the peers | ||
283 | PEERINFO_INFO_END = 333 // End of information about other peers | ||
284 | PEERINFO_NOTIFY = 334 // Start notifying this client about changes | ||
285 | |||
286 | //------------------------------------------------------------------ | ||
287 | // ATS message types | ||
288 | //------------------------------------------------------------------ | ||
289 | |||
290 | ATS_START = 340 // Type of the 'struct ClientStartMessage' sent by clients to ATS to identify the type of the client. | ||
291 | ATS_REQUEST_ADDRESS = 341 // Type of the 'struct RequestAddressMessage' sent by clients to request an address to help connect. | ||
292 | ATS_REQUEST_ADDRESS_CANCEL = 342 // Type of the 'struct RequestAddressMessage' sent by clients to request an address to help connect. | ||
293 | ATS_ADDRESS_UPDATE = 343 // Type of the 'struct AddressUpdateMessage' sent by clients to ATS to inform ATS about performance changes. | ||
294 | ATS_ADDRESS_DESTROYED = 344 // Type of the 'struct AddressDestroyedMessage' sent by clients to ATS to inform ATS about an address being unavailable. | ||
295 | ATS_ADDRESS_SUGGESTION = 345 // Type of the 'struct AddressSuggestionMessage' sent by ATS to clients to suggest switching to a different address. | ||
296 | ATS_PEER_INFORMATION = 346 // Type of the 'struct PeerInformationMessage' sent by ATS to clients to inform about QoS for a particular connection. | ||
297 | ATS_RESERVATION_REQUEST = 347 // Type of the 'struct ReservationRequestMessage' sent by clients to ATS to ask for inbound bandwidth reservations. | ||
298 | ATS_RESERVATION_RESULT = 348 // Type of the 'struct ReservationResultMessage' sent by ATS to clients in response to a reservation request. | ||
299 | ATS_PREFERENCE_CHANGE = 349 // Type of the 'struct ChangePreferenceMessage' sent by clients to ATS to ask for allocation preference changes. | ||
300 | ATS_SESSION_RELEASE = 350 // Type of the 'struct SessionReleaseMessage' sent by ATS to client to confirm that a session ID was destroyed. | ||
301 | ATS_ADDRESS_ADD = 353 // Type of the 'struct AddressUpdateMessage' sent by client to ATS to add a new address | ||
302 | ATS_ADDRESSLIST_REQUEST = 354 // Type of the 'struct AddressListRequestMessage' sent by client to ATS to request information about addresses | ||
303 | ATS_ADDRESSLIST_RESPONSE = 355 // Type of the 'struct AddressListResponseMessage' sent by ATS to client with information about addresses | ||
304 | ATS_PREFERENCE_FEEDBACK = 356 // Type of the 'struct ChangePreferenceMessage' sent by clients to ATS to ask for allocation preference changes. | ||
305 | |||
306 | //------------------------------------------------------------------ | ||
307 | // TRANSPORT message types | ||
308 | //------------------------------------------------------------------ | ||
309 | |||
310 | 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. | ||
311 | TRANSPORT_CONNECT = 361 // Message from TRANSPORT notifying about a client that connected to us. | ||
312 | TRANSPORT_DISCONNECT = 362 // Message from TRANSPORT notifying about a client that disconnected from us. | ||
313 | TRANSPORT_SEND = 363 // Request to TRANSPORT to transmit a message. | ||
314 | 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. | ||
315 | TRANSPORT_RECV = 365 // Message from TRANSPORT notifying about a message that was received. | ||
316 | TRANSPORT_SET_QUOTA = 366 // Message telling transport to limit its receive rate. | ||
317 | TRANSPORT_ADDRESS_TO_STRING = 367 // Request to look addresses of peers in server. | ||
318 | TRANSPORT_ADDRESS_TO_STRING_REPLY = 368 // Response to the address lookup request. | ||
319 | TRANSPORT_BLACKLIST_INIT = 369 // Register a client that wants to do blacklisting. | ||
320 | TRANSPORT_BLACKLIST_QUERY = 370 // Query to a blacklisting client (is this peer blacklisted)? | ||
321 | TRANSPORT_BLACKLIST_REPLY = 371 // Reply from blacklisting client (answer to blacklist query). | ||
322 | TRANSPORT_PING = 372 // Transport PING message | ||
323 | TRANSPORT_PONG = 373 // Transport PONG message | ||
324 | TRANSPORT_SESSION_SYN = 375 // Transport SYN message exchanged between transport services to indicate that a session should be marked as 'connected'. | ||
325 | TRANSPORT_SESSION_SYN_ACK = 376 // Transport SYN_ACK message exchanged between transport services to indicate that a SYN message was accepted | ||
326 | TRANSPORT_SESSION_ACK = 377 // Transport ACK message exchanged between transport services to indicate that a SYN_ACK message was accepted | ||
327 | TRANSPORT_SESSION_DISCONNECT = 378 // Transport DISCONNECT message exchanged between transport services to indicate that a connection should be dropped. | ||
328 | TRANSPORT_SESSION_QUOTA = 379 // Message exchanged between transport services to indicate that the sender should limit its transmission rate to the indicated quota. | ||
329 | TRANSPORT_MONITOR_PEER_REQUEST = 380 // Request to monitor addresses used by a peer or all peers. | ||
330 | 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 | ||
331 | TRANSPORT_SESSION_KEEPALIVE_RESPONSE = 382 // Response to a #TRANSPORT_SESSION_KEEPALIVE message to measure latency in a regular interval | ||
332 | TRANSPORT_MONITOR_PEER_RESPONSE = 383 // Response to #TRANSPORT_MONITOR_PEER_REQUEST request to iterate over all known addresses. | ||
333 | TRANSPORT_BROADCAST_BEACON = 384 // Message send by a peer to notify the other to keep the session alive. | ||
334 | TRANSPORT_TRAFFIC_METRIC = 385 // Message containing traffic metrics for transport service | ||
335 | TRANSPORT_MONITOR_PLUGIN_START = 388 // Request to start monitoring the connection state of plugins. | ||
336 | 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 | ||
337 | 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. | ||
338 | TRANSPORT_MONITOR_PEER_RESPONSE_END = 391 // terminating list of replies. | ||
339 | |||
340 | //------------------------------------------------------------------ | ||
341 | // FS-PUBLISH-HELPER IPC Messages | ||
342 | //------------------------------------------------------------------ | ||
343 | |||
344 | FS_PUBLISH_HELPER_PROGRESS_FILE = 420 // Progress information from the helper: found a file | ||
345 | FS_PUBLISH_HELPER_PROGRESS_DIRECTORY = 421 // Progress information from the helper: found a directory | ||
346 | FS_PUBLISH_HELPER_ERROR = 422 // Error signal from the helper. | ||
347 | FS_PUBLISH_HELPER_SKIP_FILE = 423 // Signal that helper skipped a file. | ||
348 | FS_PUBLISH_HELPER_COUNTING_DONE = 424 // Signal that helper is done scanning the directory tree. | ||
349 | FS_PUBLISH_HELPER_META_DATA = 425 // Extracted meta data from the helper. | ||
350 | FS_PUBLISH_HELPER_FINISHED = 426 // Signal that helper is done. | ||
351 | |||
352 | //------------------------------------------------------------------ | ||
353 | // NAMECACHE message types | ||
354 | //------------------------------------------------------------------ | ||
355 | |||
356 | NAMECACHE_LOOKUP_BLOCK = 431 // Client to service: lookup block | ||
357 | NAMECACHE_LOOKUP_BLOCK_RESPONSE = 432 // Service to client: result of block lookup | ||
358 | NAMECACHE_BLOCK_CACHE = 433 // Client to service: cache a block | ||
359 | NAMECACHE_BLOCK_CACHE_RESPONSE = 434 // Service to client: result of block cache request | ||
360 | |||
361 | //------------------------------------------------------------------ | ||
362 | // NAMESTORE message types | ||
363 | //------------------------------------------------------------------ | ||
364 | |||
365 | NAMESTORE_RECORD_STORE = 435 // Client to service: store records (as authority) | ||
366 | NAMESTORE_RECORD_STORE_RESPONSE = 436 // Service to client: result of store operation. | ||
367 | NAMESTORE_RECORD_LOOKUP = 437 // Client to service: lookup label | ||
368 | NAMESTORE_RECORD_LOOKUP_RESPONSE = 438 // Service to client: lookup label | ||
369 | NAMESTORE_ZONE_TO_NAME = 439 // Client to service: "reverse" lookup for zone name based on zone key | ||
370 | NAMESTORE_ZONE_TO_NAME_RESPONSE = 440 // Service to client: result of zone-to-name lookup. | ||
371 | NAMESTORE_MONITOR_START = 441 // Client to service: start monitoring (yields sequence of "ZONE_ITERATION_RESPONSES" --- forever). | ||
372 | NAMESTORE_MONITOR_SYNC = 442 // Service to client: you're now in sync. | ||
373 | NAMESTORE_RECORD_RESULT = 443 // Service to client: here is a (plaintext) record you requested. | ||
374 | 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. | ||
375 | NAMESTORE_ZONE_ITERATION_START = 445 // Client to service: please start iteration; receives "NAMESTORE_LOOKUP_NAME_RESPONSE" messages in return. | ||
376 | NAMESTORE_ZONE_ITERATION_NEXT = 447 // Client to service: next record(s) in iteration please. | ||
377 | NAMESTORE_ZONE_ITERATION_STOP = 448 // Client to service: stop iterating. | ||
378 | |||
379 | //------------------------------------------------------------------ | ||
380 | // LOCKMANAGER message types | ||
381 | //------------------------------------------------------------------ | ||
382 | |||
383 | LOCKMANAGER_ACQUIRE = 450 // Message to acquire Lock | ||
384 | LOCKMANAGER_RELEASE = 451 // Message to release lock | ||
385 | LOCKMANAGER_SUCCESS = 452 // SUCCESS reply from lockmanager | ||
386 | |||
387 | //------------------------------------------------------------------ | ||
388 | // TESTBED message types | ||
389 | //------------------------------------------------------------------ | ||
390 | |||
391 | TESTBED_INIT = 460 // Initial message from a client to a testing control service | ||
392 | TESTBED_ADD_HOST = 461 // Message to add host | ||
393 | TESTBED_ADD_HOST_SUCCESS = 462 // Message to signal that a add host succeeded | ||
394 | TESTBED_LINK_CONTROLLERS = 463 // Message to link delegated controller to slave controller | ||
395 | TESTBED_CREATE_PEER = 464 // Message to create a peer at a host | ||
396 | TESTBED_RECONFIGURE_PEER = 465 // Message to reconfigure a peer | ||
397 | TESTBED_START_PEER = 466 // Message to start a peer at a host | ||
398 | TESTBED_STOP_PEER = 467 // Message to stop a peer at a host | ||
399 | TESTBED_DESTROY_PEER = 468 // Message to destroy a peer | ||
400 | TESTBED_CONFIGURE_UNDERLAY_LINK = 469 // Configure underlay link message | ||
401 | TESTBED_OVERLAY_CONNECT = 470 // Message to connect peers in a overlay | ||
402 | TESTBED_PEER_EVENT = 471 // Message for peer events | ||
403 | TESTBED_PEER_CONNECT_EVENT = 472 // Message for peer connect events | ||
404 | TESTBED_OPERATION_FAIL_EVENT = 473 // Message for operation events | ||
405 | TESTBED_CREATE_PEER_SUCCESS = 474 // Message to signal successful peer creation | ||
406 | TESTBED_GENERIC_OPERATION_SUCCESS = 475 // Message to signal a generic operation has been successful | ||
407 | TESTBED_GET_PEER_INFORMATION = 476 // Message to get a peer's information | ||
408 | TESTBED_PEER_INFORMATION = 477 // Message containing the peer's information | ||
409 | 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 | ||
410 | TESTBED_GET_SLAVE_CONFIGURATION = 479 // Message to request configuration of a slave controller | ||
411 | TESTBED_SLAVE_CONFIGURATION = 480 // Message which contains the configuration of slave controller | ||
412 | TESTBED_LINK_CONTROLLERS_RESULT = 481 // Message to signal the result of #TESTBED_LINK_CONTROLLERS request | ||
413 | TESTBED_SHUTDOWN_PEERS = 482 // A controller receiving this message floods it to its directly-connected sub-controllers and then stops and destroys all peers | ||
414 | TESTBED_MANAGE_PEER_SERVICE = 483 // Message to start/stop a service of a peer | ||
415 | TESTBED_BARRIER_INIT = 484 // Message to initialise a barrier. Messages of these type are flooded to all sub-controllers | ||
416 | TESTBED_BARRIER_CANCEL = 485 // Message to cancel a barrier. This message is flooded to all sub-controllers | ||
417 | TESTBED_BARRIER_STATUS = 486 // Message for signalling status of a barrier | ||
418 | TESTBED_BARRIER_WAIT = 487 // Message sent by a peer when it has reached a barrier and is waiting for it to be crossed | ||
419 | 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 | ||
420 | TESTBED_HELPER_INIT = 495 // The initialization message towards gnunet-testbed-helper | ||
421 | TESTBED_HELPER_REPLY = 496 // The reply message from gnunet-testbed-helper | ||
422 | |||
423 | //------------------------------------------------------------------ | ||
424 | // GNS. | ||
425 | //------------------------------------------------------------------ | ||
426 | |||
427 | GNS_LOOKUP = 500 // Client would like to resolve a name. | ||
428 | GNS_LOOKUP_RESULT = 501 // Service response to name resolution request from client. | ||
429 | GNS_REVERSE_LOOKUP = 502 // Reverse lookup | ||
430 | GNS_REVERSE_LOOKUP_RESULT = 503 // Response to reverse lookup | ||
431 | |||
432 | //------------------------------------------------------------------ | ||
433 | // CONSENSUS message types | ||
434 | //------------------------------------------------------------------ | ||
435 | |||
436 | CONSENSUS_CLIENT_JOIN = 520 // Join a consensus session. Sent by client to service as first message. | ||
437 | CONSENSUS_CLIENT_INSERT = 521 // Insert an element. Sent by client to service. | ||
438 | CONSENSUS_CLIENT_BEGIN = 522 // Begin accepting new elements from other participants. Sent by client to service. | ||
439 | CONSENSUS_CLIENT_RECEIVED_ELEMENT = 523 // Sent by service when a new element is added. | ||
440 | CONSENSUS_CLIENT_CONCLUDE = 524 // Sent by client to service in order to start the consensus conclusion. | ||
441 | 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. | ||
442 | CONSENSUS_CLIENT_ACK = 540 // Sent by client to service, telling whether a received element should be accepted and propagated further or not. | ||
443 | CONSENSUS_P2P_DELTA_ESTIMATE = 541 // Strata estimator. | ||
444 | CONSENSUS_P2P_DIFFERENCE_DIGEST = 542 // IBF containing all elements of a peer. | ||
445 | CONSENSUS_P2P_ELEMENTS = 543 // One or more elements that are sent from peer to peer. | ||
446 | CONSENSUS_P2P_ELEMENTS_REQUEST = 544 // Elements, and requests for further elements | ||
447 | CONSENSUS_P2P_ELEMENTS_REPORT = 545 // Elements that a peer reports to be missing at the remote peer. | ||
448 | CONSENSUS_P2P_HELLO = 546 // Initialization message for consensus p2p communication. | ||
449 | CONSENSUS_P2P_SYNCED = 547 // Report that the peer is synced with the partner after successfully decoding the invertible bloom filter. | ||
450 | CONSENSUS_P2P_FIN = 548 // Interaction os over, got synched and reported all elements | ||
451 | CONSENSUS_P2P_ABORT = 548 // Abort a round, don't send requested elements anymore | ||
452 | CONSENSUS_P2P_ROUND_CONTEXT = 547 // Abort a round, don't send requested elements anymore | ||
453 | |||
454 | //------------------------------------------------------------------ | ||
455 | // SET message types | ||
456 | //------------------------------------------------------------------ | ||
457 | |||
458 | SET_UNION_P2P_REQUEST_FULL = 565 // Demand the whole element from the other peer, given only the hash code. | ||
459 | SET_UNION_P2P_DEMAND = 566 // Demand the whole element from the other peer, given only the hash code. | ||
460 | SET_UNION_P2P_INQUIRY = 567 // Tell the other peer to send us a list of hashes that match an IBF key. | ||
461 | SET_UNION_P2P_OFFER = 568 // Tell the other peer which hashes match a given IBF key. | ||
462 | SET_REJECT = 569 // Reject a set request. | ||
463 | SET_CANCEL = 570 // Cancel a set operation | ||
464 | SET_ITER_ACK = 571 // Acknowledge result from iteration | ||
465 | SET_RESULT = 572 // Create an empty set | ||
466 | SET_ADD = 573 // Add element to set | ||
467 | SET_REMOVE = 574 // Remove element from set | ||
468 | SET_LISTEN = 575 // Listen for operation requests | ||
469 | SET_ACCEPT = 576 // Accept a set request | ||
470 | SET_EVALUATE = 577 // Evaluate a set operation | ||
471 | SET_CONCLUDE = 578 // Start a set operation with the given set | ||
472 | SET_REQUEST = 579 // Notify the client of a request from a remote peer | ||
473 | SET_CREATE = 580 // Create a new local set | ||
474 | SET_P2P_OPERATION_REQUEST = 581 // Request a set operation from a remote peer. | ||
475 | SET_UNION_P2P_SE = 582 // Strata estimator. | ||
476 | SET_UNION_P2P_IBF = 583 // Invertible bloom filter. | ||
477 | SET_P2P_ELEMENTS = 584 // Actual set elements. | ||
478 | SET_P2P_ELEMENT_REQUESTS = 585 // Requests for the elements with the given hashes. | ||
479 | SET_UNION_P2P_DONE = 586 // Set operation is done. | ||
480 | SET_ITER_REQUEST = 587 // Start iteration over set elements. | ||
481 | SET_ITER_ELEMENT = 588 // Element result for the iterating client. | ||
482 | SET_ITER_DONE = 589 // Iteration end marker for the client. | ||
483 | SET_UNION_P2P_SEC = 590 // Compressed strata estimator. | ||
484 | SET_INTERSECTION_P2P_ELEMENT_INFO = 591 // Information about the element count for intersection | ||
485 | SET_INTERSECTION_P2P_BF = 592 // Bloom filter message for intersection exchange started by Bob. | ||
486 | SET_INTERSECTION_P2P_DONE = 593 // Intersection operation is done. | ||
487 | SET_COPY_LAZY_PREPARE = 594 // Ask the set service to prepare a copy of a set. | ||
488 | SET_COPY_LAZY_RESPONSE = 595 // Give the client an ID for connecting to the set's copy. | ||
489 | SET_COPY_LAZY_CONNECT = 596 // Sent by the client to the server to connect to an existing, lazily copied set. | ||
490 | 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. | ||
491 | SET_UNION_P2P_FULL_ELEMENT = 598 // Send a set element, not as response to a demand but because we're sending the full set. | ||
492 | 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. | ||
493 | |||
494 | //------------------------------------------------------------------ | ||
495 | // TESTBED LOGGER message types | ||
496 | //------------------------------------------------------------------ | ||
497 | |||
498 | TESTBED_LOGGER_MSG = 600 // Message for TESTBED LOGGER | ||
499 | TESTBED_LOGGER_ACK = 601 // Message for TESTBED LOGGER acknowledgement | ||
500 | |||
501 | REGEX_ANNOUNCE = 620 // Advertise regex capability. | ||
502 | REGEX_SEARCH = 621 // Search for peer with matching capability. | ||
503 | REGEX_RESULT = 622 // Result in response to regex search. | ||
504 | |||
505 | //------------------------------------------------------------------ | ||
506 | // IDENTITY message types | ||
507 | //------------------------------------------------------------------ | ||
508 | |||
509 | IDENTITY_START = 624 // First message send from identity client to service (to subscribe to updates). | ||
510 | IDENTITY_RESULT_CODE = 625 // Generic response from identity service with success and/or error message. | ||
511 | IDENTITY_UPDATE = 626 // Update about identity status from service to clients. | ||
512 | IDENTITY_GET_DEFAULT = 627 // Client requests to know default identity for a subsystem. | ||
513 | IDENTITY_SET_DEFAULT = 628 // Client sets default identity; or service informs about default identity. | ||
514 | IDENTITY_CREATE = 629 // Create new identity (client->service). | ||
515 | IDENTITY_RENAME = 630 // Rename existing identity (client->service). | ||
516 | IDENTITY_DELETE = 631 // Delete identity (client->service). | ||
517 | IDENTITY_LOOKUP = 632 | ||
518 | IDENTITY_LOOKUP_BY_NAME = 633 | ||
519 | |||
520 | //------------------------------------------------------------------ | ||
521 | // REVOCATION message types | ||
522 | //------------------------------------------------------------------ | ||
523 | |||
524 | REVOCATION_QUERY = 636 // Client to service: was this key revoked? | ||
525 | REVOCATION_QUERY_RESPONSE = 637 // Service to client: answer if key was revoked! | ||
526 | REVOCATION_REVOKE = 638 // Client to service OR peer-to-peer: revoke this key! | ||
527 | REVOCATION_REVOKE_RESPONSE = 639 // Service to client: revocation confirmed | ||
528 | |||
529 | //------------------------------------------------------------------ | ||
530 | // SCALARPRODUCT message types | ||
531 | //------------------------------------------------------------------ | ||
532 | |||
533 | SCALARPRODUCT_CLIENT_TO_ALICE = 640 // Client -> Alice | ||
534 | SCALARPRODUCT_CLIENT_TO_BOB = 641 // Client -> Bob | ||
535 | SCALARPRODUCT_CLIENT_MULTIPART_ALICE = 642 // Client -> Alice multipart | ||
536 | SCALARPRODUCT_CLIENT_MULTIPART_BOB = 643 // Client -> Bob multipart | ||
537 | SCALARPRODUCT_SESSION_INITIALIZATION = 644 // Alice -> Bob session initialization | ||
538 | SCALARPRODUCT_ALICE_CRYPTODATA = 645 // Alice -> Bob SP crypto-data (after intersection) | ||
539 | SCALARPRODUCT_BOB_CRYPTODATA = 647 // Bob -> Alice SP crypto-data | ||
540 | SCALARPRODUCT_BOB_CRYPTODATA_MULTIPART = 648 // Bob -> Alice SP crypto-data multipart | ||
541 | SCALARPRODUCT_RESULT = 649 // Alice/Bob -> Client Result | ||
542 | SCALARPRODUCT_ECC_SESSION_INITIALIZATION = 650 // Alice -> Bob ECC session initialization | ||
543 | SCALARPRODUCT_ECC_ALICE_CRYPTODATA = 651 // Alice -> Bob ECC crypto data | ||
544 | SCALARPRODUCT_ECC_BOB_CRYPTODATA = 652 // Bob -> Alice ECC crypto data | ||
545 | |||
546 | //------------------------------------------------------------------ | ||
547 | // PSYCSTORE message types | ||
548 | //------------------------------------------------------------------ | ||
549 | |||
550 | PSYCSTORE_MEMBERSHIP_STORE = 660 // Store a membership event. | ||
551 | PSYCSTORE_MEMBERSHIP_TEST = 661 // Test for membership of a member at a particular point in time. | ||
552 | PSYCSTORE_FRAGMENT_STORE = 662 // | ||
553 | PSYCSTORE_FRAGMENT_GET = 663 // | ||
554 | PSYCSTORE_MESSAGE_GET = 664 // | ||
555 | PSYCSTORE_MESSAGE_GET_FRAGMENT = 665 // | ||
556 | PSYCSTORE_COUNTERS_GET = 666 // | ||
557 | PSYCSTORE_STATE_MODIFY = 668 // | ||
558 | PSYCSTORE_STATE_SYNC = 669 // | ||
559 | PSYCSTORE_STATE_RESET = 670 // | ||
560 | PSYCSTORE_STATE_HASH_UPDATE = 671 // | ||
561 | PSYCSTORE_STATE_GET = 672 // | ||
562 | PSYCSTORE_STATE_GET_PREFIX = 673 // | ||
563 | PSYCSTORE_RESULT_CODE = 674 // Generic response from PSYCstore service with success and/or error message. | ||
564 | PSYCSTORE_RESULT_FRAGMENT = 675 // | ||
565 | PSYCSTORE_RESULT_COUNTERS = 676 // | ||
566 | PSYCSTORE_RESULT_STATE = 677 // | ||
567 | |||
568 | //------------------------------------------------------------------ | ||
569 | // PSYC message types | ||
570 | //------------------------------------------------------------------ | ||
571 | |||
572 | PSYC_RESULT_CODE = 680 // S->C: result of an operation | ||
573 | PSYC_MASTER_START = 681 // C->S: request to start a channel as a master | ||
574 | PSYC_MASTER_START_ACK = 682 // S->C: master start acknowledgement | ||
575 | PSYC_SLAVE_JOIN = 683 // C->S: request to join a channel as a slave | ||
576 | PSYC_SLAVE_JOIN_ACK = 684 // S->C: slave join acknowledgement | ||
577 | PSYC_PART_REQUEST = 685 // C->S: request to part from a channel | ||
578 | PSYC_PART_ACK = 686 // S->C: acknowledgement that a slave of master parted from a channel | ||
579 | PSYC_JOIN_REQUEST = 687 // M->S->C: incoming join request from multicast | ||
580 | PSYC_JOIN_DECISION = 688 // C->S->M: decision about a join request | ||
581 | PSYC_CHANNEL_MEMBERSHIP_STORE = 689 // C->S: request to add/remove channel slave in the membership database. | ||
582 | PSYC_MESSAGE = 691 // S<--C: PSYC message which contains one or more message parts. | ||
583 | PSYC_MESSAGE_HEADER = 692 // M<->S<->C: PSYC message which contains a header and one or more message parts. | ||
584 | PSYC_MESSAGE_METHOD = 693 // Message part: method | ||
585 | PSYC_MESSAGE_MODIFIER = 694 // Message part: modifier | ||
586 | PSYC_MESSAGE_MOD_CONT = 695 // Message part: modifier continuation | ||
587 | PSYC_MESSAGE_DATA = 696 // Message part: data | ||
588 | PSYC_MESSAGE_END = 697 // Message part: end of message | ||
589 | PSYC_MESSAGE_CANCEL = 698 // Message part: message cancelled | ||
590 | PSYC_MESSAGE_ACK = 699 // S->C: message acknowledgement | ||
591 | PSYC_HISTORY_REPLAY = 701 // C->S: request channel history replay from PSYCstore. | ||
592 | PSYC_HISTORY_RESULT = 702 // S->C: result for a channel history request | ||
593 | PSYC_STATE_GET = 703 // C->S: request best matching state variable from PSYCstore. | ||
594 | PSYC_STATE_GET_PREFIX = 704 // C->S: request state variables with a given prefix from PSYCstore. | ||
595 | PSYC_STATE_RESULT = 705 // S->C: result for a state request. | ||
596 | |||
597 | //------------------------------------------------------------------ | ||
598 | // CONVERSATION message types | ||
599 | //------------------------------------------------------------------ | ||
600 | |||
601 | CONVERSATION_AUDIO = 730 // Message to transmit the audio between helper and speaker/microphone library. | ||
602 | CONVERSATION_CS_PHONE_REGISTER = 731 // Client -> Server message to register a phone. | ||
603 | CONVERSATION_CS_PHONE_PICK_UP = 732 // Client -> Server message to reject/hangup a call | ||
604 | CONVERSATION_CS_PHONE_HANG_UP = 733 // Client -> Server message to reject/hangup a call | ||
605 | CONVERSATION_CS_PHONE_CALL = 734 // Client <- Server message to indicate a ringing phone | ||
606 | CONVERSATION_CS_PHONE_RING = 735 // Client <- Server message to indicate a ringing phone | ||
607 | CONVERSATION_CS_PHONE_SUSPEND = 736 // Client <-> Server message to suspend connection. | ||
608 | CONVERSATION_CS_PHONE_RESUME = 737 // Client <-> Server message to resume connection. | ||
609 | CONVERSATION_CS_PHONE_PICKED_UP = 738 // Service -> Client message to notify that phone was picked up. | ||
610 | CONVERSATION_CS_AUDIO = 739 // Client <-> Server message to send audio data. | ||
611 | CONVERSATION_CADET_PHONE_RING = 740 // Cadet: call initiation | ||
612 | CONVERSATION_CADET_PHONE_HANG_UP = 741 // Cadet: hang up / refuse call | ||
613 | CONVERSATION_CADET_PHONE_PICK_UP = 742 // Cadet: pick up phone (establish audio channel) | ||
614 | CONVERSATION_CADET_PHONE_SUSPEND = 743 // Cadet: phone suspended. | ||
615 | CONVERSATION_CADET_PHONE_RESUME = 744 // Cadet: phone resumed. | ||
616 | CONVERSATION_CADET_AUDIO = 745 // Cadet: audio data | ||
617 | |||
618 | //------------------------------------------------------------------ | ||
619 | // MULTICAST message types | ||
620 | //------------------------------------------------------------------ | ||
621 | |||
622 | MULTICAST_ORIGIN_START = 750 // C->S: Start the origin. | ||
623 | MULTICAST_MEMBER_JOIN = 751 // C->S: Join group as a member. | ||
624 | MULTICAST_JOIN_REQUEST = 752 // C<--S<->T: A peer wants to join the group. Unicast message to the origin or another group member. | ||
625 | MULTICAST_JOIN_DECISION = 753 // C<->S<->T: Response to a join request. Unicast message from a group member to the peer wanting to join. | ||
626 | MULTICAST_PART_REQUEST = 754 // A peer wants to part the group. | ||
627 | MULTICAST_PART_ACK = 755 // Acknowledgement sent in response to a part request. Unicast message from a group member to the peer wanting to part. | ||
628 | MULTICAST_GROUP_END = 756 // Group terminated. | ||
629 | MULTICAST_MESSAGE = 757 // C<->S<->T: Multicast message from the origin to all members. | ||
630 | MULTICAST_REQUEST = 758 // C<->S<->T: Unicast request from a group member to the origin. | ||
631 | MULTICAST_FRAGMENT_ACK = 759 // C->S: Acknowledgement of a message or request fragment for the client. | ||
632 | MULTICAST_REPLAY_REQUEST = 760 // C<->S<->T: Replay request from a group member to another member. | ||
633 | MULTICAST_REPLAY_RESPONSE = 761 // C<->S<->T: Replay response from a group member to another member. | ||
634 | MULTICAST_REPLAY_RESPONSE_END = 762 // C<->S: End of replay response. | ||
635 | |||
636 | //------------------------------------------------------------------ | ||
637 | // SECRETSHARING message types | ||
638 | //------------------------------------------------------------------ | ||
639 | |||
640 | SECRETSHARING_CLIENT_GENERATE = 780 // Establish a new session. | ||
641 | SECRETSHARING_CLIENT_DECRYPT = 781 // Request the decryption of a ciphertext. | ||
642 | SECRETSHARING_CLIENT_DECRYPT_DONE = 782 // The service succeeded in decrypting a ciphertext. | ||
643 | SECRETSHARING_CLIENT_SECRET_READY = 783 // Contains the peer's share. | ||
644 | |||
645 | //------------------------------------------------------------------ | ||
646 | // PEERSTORE message types | ||
647 | //------------------------------------------------------------------ | ||
648 | |||
649 | PEERSTORE_STORE = 820 // Store request message | ||
650 | PEERSTORE_ITERATE = 821 // Iteration request | ||
651 | PEERSTORE_ITERATE_RECORD = 822 // Iteration record message | ||
652 | PEERSTORE_ITERATE_END = 823 // Iteration end message | ||
653 | PEERSTORE_WATCH = 824 // Watch request | ||
654 | PEERSTORE_WATCH_RECORD = 825 // Watch response | ||
655 | PEERSTORE_WATCH_CANCEL = 826 // Watch cancel request | ||
656 | |||
657 | //------------------------------------------------------------------ | ||
658 | // SOCIAL message types | ||
659 | //------------------------------------------------------------------ | ||
660 | |||
661 | SOCIAL_RESULT_CODE = 840 // S->C: result of an operation | ||
662 | SOCIAL_HOST_ENTER = 841 // C->S: request to enter a place as the host | ||
663 | SOCIAL_HOST_ENTER_ACK = 842 // S->C: host enter acknowledgement | ||
664 | SOCIAL_GUEST_ENTER = 843 // C->S: request to enter a place as a guest | ||
665 | SOCIAL_GUEST_ENTER_BY_NAME = 844 // C->S: request to enter a place as a guest, using a GNS address | ||
666 | SOCIAL_GUEST_ENTER_ACK = 845 // S->C: guest enter acknowledgement | ||
667 | SOCIAL_ENTRY_REQUEST = 846 // P->S->C: incoming entry request from PSYC | ||
668 | SOCIAL_ENTRY_DECISION = 847 // C->S->P: decision about an entry request | ||
669 | SOCIAL_PLACE_LEAVE = 848 // C->S: request to leave a place | ||
670 | SOCIAL_PLACE_LEAVE_ACK = 849 // S->C: place leave acknowledgement | ||
671 | SOCIAL_ZONE_ADD_PLACE = 850 // C->S: add place to GNS zone | ||
672 | SOCIAL_ZONE_ADD_NYM = 851 // C->S: add nym to GNS zone | ||
673 | SOCIAL_APP_CONNECT = 852 // C->S: connect application | ||
674 | SOCIAL_APP_DETACH = 853 // C->S: detach a place from application | ||
675 | SOCIAL_APP_EGO = 854 // S->C: notify about an existing ego | ||
676 | SOCIAL_APP_EGO_END = 855 // S->C: end of ego list | ||
677 | SOCIAL_APP_PLACE = 856 // S->C: notify about an existing place | ||
678 | SOCIAL_APP_PLACE_END = 857 // S->C: end of place list | ||
679 | SOCIAL_MSG_PROC_SET = 858 // C->S: set message processing flags | ||
680 | SOCIAL_MSG_PROC_CLEAR = 859 // C->S: clear message processing flags | ||
681 | |||
682 | //------------------------------------------------------------------ | ||
683 | // X-VINE DHT messages | ||
684 | //------------------------------------------------------------------ | ||
685 | |||
686 | XDHT_P2P_TRAIL_SETUP = 880 // Trail setup request is received by a peer. | ||
687 | XDHT_P2P_TRAIL_SETUP_RESULT = 881 // Trail to a particular peer is returned to this peer. | ||
688 | XDHT_P2P_VERIFY_SUCCESSOR = 882 // Verify if your immediate successor is still your immediate successor. | ||
689 | XDHT_P2P_NOTIFY_NEW_SUCCESSOR = 883 // Notify your new immediate successor that you are its new predecessor. | ||
690 | XDHT_P2P_VERIFY_SUCCESSOR_RESULT = 884 // Message which contains the immediate predecessor of requested successor | ||
691 | XDHT_P2P_GET_RESULT = 885 // Message which contains the get result. | ||
692 | XDHT_P2P_TRAIL_SETUP_REJECTION = 886 // Trail Rejection Message. | ||
693 | XDHT_P2P_TRAIL_TEARDOWN = 887 // Trail Tear down Message. | ||
694 | XDHT_P2P_ADD_TRAIL = 888 // Routing table add message. | ||
695 | XDHT_P2P_PUT = 890 // Peer is storing the data in DHT. | ||
696 | XDHT_P2P_GET = 891 // Peer tries to find data in DHT. | ||
697 | XDHT_P2P_NOTIFY_SUCCESSOR_CONFIRMATION = 892 // Send back peer that considers you are its successor. | ||
698 | |||
699 | DHT_ACT_MALICIOUS = 893 // Turn X-VINE DHT service malicious | ||
700 | DHT_CLIENT_ACT_MALICIOUS_OK = 894 // Acknowledge receiving ACT MALICIOUS request | ||
701 | |||
702 | //------------------------------------------------------------------ | ||
703 | // Whanau DHT messages | ||
704 | //------------------------------------------------------------------ | ||
705 | |||
706 | WDHT_RANDOM_WALK = 910 // This message contains the query for performing a random walk | ||
707 | WDHT_RANDOM_WALK_RESPONSE = 911 // This message contains the result of a random walk | ||
708 | WDHT_TRAIL_DESTROY = 912 // This message contains a notification for the death of a trail | ||
709 | WDHT_TRAIL_ROUTE = 913 // This message are used to route a query to a peer | ||
710 | WDHT_SUCCESSOR_FIND = 914 // This message contains the query to transfer successor values. | ||
711 | WDHT_GET = 915 // Message which contains the get query | ||
712 | WDHT_PUT = 916 // Message which contains the "put", a response to #WDHT_SUCCESSOR_FIND. | ||
713 | WDHT_GET_RESULT = 917 // Message which contains the get result, a response to #WDHT_GET. | ||
714 | |||
715 | //------------------------------------------------------------------ | ||
716 | // RPS messages | ||
717 | //------------------------------------------------------------------ | ||
718 | |||
719 | RPS_PP_CHECK_LIVE = 950 // RPS check liveliness message to check liveliness of other peer | ||
720 | RPS_PP_PUSH = 951 // RPS PUSH message to push own ID to another peer | ||
721 | RPS_PP_PULL_REQUEST = 952 // RPS PULL REQUEST message to request the local view of another peer | ||
722 | RPS_PP_PULL_REPLY = 953 // RPS PULL REPLY message which contains the view of the other peer | ||
723 | RPS_CS_SEED = 954 // RPS CS SEED Message for the Client to seed peers into rps | ||
724 | RPS_ACT_MALICIOUS = 955 // Turn RPS service malicious | ||
725 | RPS_CS_SUB_START = 956 // RPS client-service message to start a sub sampler | ||
726 | RPS_CS_SUB_STOP = 957 // RPS client-service message to stop a sub sampler | ||
727 | |||
728 | //------------------------------------------------------------------ | ||
729 | // RECLAIM messages | ||
730 | //------------------------------------------------------------------ | ||
731 | |||
732 | RECLAIM_ATTRIBUTE_STORE = 961 | ||
733 | RECLAIM_SUCCESS_RESPONSE = 962 | ||
734 | RECLAIM_ATTRIBUTE_ITERATION_START = 963 | ||
735 | RECLAIM_ATTRIBUTE_ITERATION_STOP = 964 | ||
736 | RECLAIM_ATTRIBUTE_ITERATION_NEXT = 965 | ||
737 | RECLAIM_ATTRIBUTE_RESULT = 966 | ||
738 | RECLAIM_ISSUE_TICKET = 967 | ||
739 | RECLAIM_TICKET_RESULT = 968 | ||
740 | RECLAIM_REVOKE_TICKET = 969 | ||
741 | RECLAIM_REVOKE_TICKET_RESULT = 970 | ||
742 | RECLAIM_CONSUME_TICKET = 971 | ||
743 | RECLAIM_CONSUME_TICKET_RESULT = 972 | ||
744 | RECLAIM_TICKET_ITERATION_START = 973 | ||
745 | RECLAIM_TICKET_ITERATION_STOP = 974 | ||
746 | RECLAIM_TICKET_ITERATION_NEXT = 975 | ||
747 | RECLAIM_ATTRIBUTE_DELETE = 976 | ||
748 | |||
749 | //------------------------------------------------------------------ | ||
750 | // CREDENTIAL messages | ||
751 | //------------------------------------------------------------------ | ||
752 | |||
753 | CREDENTIAL_VERIFY = 981 // | ||
754 | CREDENTIAL_VERIFY_RESULT = 982 // | ||
755 | CREDENTIAL_COLLECT = 983 // | ||
756 | CREDENTIAL_COLLECT_RESULT = 984 // | ||
757 | |||
758 | //------------------------------------------------------------------ | ||
759 | // CADET messages | ||
760 | //------------------------------------------------------------------ | ||
761 | |||
762 | CADET_CONNECTION_CREATE = 1000 // Request the creation of a connection | ||
763 | CADET_CONNECTION_CREATE_ACK = 1001 // Send origin an ACK that the connection is complete | ||
764 | CADET_CONNECTION_BROKEN = 1002 // Notify that a connection is no longer valid | ||
765 | CADET_CONNECTION_DESTROY = 1003 // Request the destuction of a connection | ||
766 | CADET_CONNECTION_PATH_CHANGED_UNIMPLEMENTED = 1004 // At some point, the route will spontaneously change TODO | ||
767 | CADET_CONNECTION_HOP_BY_HOP_ENCRYPTED_ACK = 1005 // Hop-by-hop, connection dependent ACK. deprecated | ||
768 | |||
769 | 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 | ||
770 | CADET_TUNNEL_KX = 1007 // Axolotl key exchange. | ||
771 | CADET_TUNNEL_ENCRYPTED = 1008 // Axolotl encrypted data. | ||
772 | CADET_TUNNEL_KX_AUTH = 1009 // Axolotl key exchange response with authentication. | ||
773 | |||
774 | CADET_CHANNEL_APP_DATA = 1010 // Payload data (inside an encrypted tunnel). | ||
775 | CADET_CHANNEL_APP_DATA_ACK = 1011 // Confirm payload data end-to-end. | ||
776 | CADET_CHANNEL_KEEPALIVE = 1012 // Announce connection is still alive (direction sensitive). | ||
777 | CADET_CHANNEL_OPEN = 1013 // Ask the cadet service to create a new channel. | ||
778 | CADET_CHANNEL_DESTROY = 1014 // Ask the cadet service to destroy a channel. | ||
779 | CADET_CHANNEL_OPEN_ACK = 1015 // Confirm the creation of a channel | ||
780 | CADET_CHANNEL_OPEN_NACK_DEPRECATED = 1016 // Reject the creation of a channel deprecated | ||
781 | |||
782 | CADET_LOCAL_DATA = 1020 // Payload client <-> service | ||
783 | CADET_LOCAL_ACK = 1021 // Local ACK for data. | ||
784 | CADET_LOCAL_PORT_OPEN = 1022 // Start listening on a port. | ||
785 | CADET_LOCAL_PORT_CLOSE = 1023 // Stop listening on a port. | ||
786 | CADET_LOCAL_CHANNEL_CREATE = 1024 // Ask the cadet service to create a new channel. | ||
787 | CADET_LOCAL_CHANNEL_DESTROY = 1025 // Tell client that a channel was destroyed. | ||
788 | |||
789 | CADET_LOCAL_REQUEST_INFO_CHANNEL = 1030 // Local information about all channels of service. | ||
790 | CADET_LOCAL_INFO_CHANNEL = 1031 // Local information of service about a specific channel. | ||
791 | CADET_LOCAL_INFO_CHANNEL_END = 1032 // End of local information of service about channels. | ||
792 | CADET_LOCAL_REQUEST_INFO_PEERS = 1033 // Request local information about all peers known to the service. | ||
793 | CADET_LOCAL_INFO_PEERS = 1034 // Local information about all peers known to the service. | ||
794 | CADET_LOCAL_INFO_PEERS_END = 1035 // End of local information about all peers known to the service. | ||
795 | CADET_LOCAL_REQUEST_INFO_PATH = 1036 // Request local information of service about paths to specific peer. | ||
796 | CADET_LOCAL_INFO_PATH = 1037 // Local information of service about a specific path. | ||
797 | CADET_LOCAL_INFO_PATH_END = 1038 // End of local information of service about a specific path. | ||
798 | CADET_LOCAL_REQUEST_INFO_TUNNELS = 1039 // Request local information about all tunnels of service. | ||
799 | CADET_LOCAL_INFO_TUNNELS = 1040 // Local information about all tunnels of service. | ||
800 | CADET_LOCAL_INFO_TUNNELS_END = 1041 // End of local information about all tunnels of service. | ||
801 | |||
802 | CADET_CLI = 1059 // Traffic (net-cat style) used by the Command Line Interface. | ||
803 | |||
804 | //------------------------------------------------------------------ | ||
805 | // NAT messages | ||
806 | //------------------------------------------------------------------ | ||
807 | |||
808 | NAT_REGISTER = 1060 // Message to ask NAT service to register a client. | ||
809 | NAT_HANDLE_STUN = 1061 // Message to ask NAT service to handle a STUN packet. | ||
810 | NAT_REQUEST_CONNECTION_REVERSAL = 1062 // Message to ask NAT service to request connection reversal. | ||
811 | NAT_CONNECTION_REVERSAL_REQUESTED = 1063 // Message to from NAT service notifying us that connection reversal was requested by another peer. | ||
812 | NAT_ADDRESS_CHANGE = 1064 // Message to from NAT service notifying us that one of our addresses changed. | ||
813 | NAT_AUTO_REQUEST_CFG = 1066 // Message to ask NAT service to request autoconfiguration. | ||
814 | NAT_AUTO_CFG_RESULT = 1065 // Message from NAT service with the autoconfiguration result. | ||
815 | |||
816 | //------------------------------------------------------------------ | ||
817 | // AUCTION messages | ||
818 | //------------------------------------------------------------------ | ||
819 | |||
820 | AUCTION_CLIENT_CREATE = 1110 // Client wants to create a new auction. | ||
821 | AUCTION_CLIENT_JOIN = 1111 // Client wants to join an existing auction. | ||
822 | AUCTION_CLIENT_OUTCOME = 1112 // Service reports the auction outcome to the client. | ||
823 | |||
824 | //------------------------------------------------------------------ | ||
825 | // RPS_DEBUG messages | ||
826 | //------------------------------------------------------------------ | ||
827 | |||
828 | RPS_CS_DEBUG_VIEW_REQUEST = 1130 // Request updates of the view | ||
829 | RPS_CS_DEBUG_VIEW_REPLY = 1131 // Send update of the view | ||
830 | RPS_CS_DEBUG_VIEW_CANCEL = 1132 // Cancel getting updates of the view | ||
831 | RPS_CS_DEBUG_STREAM_REQUEST = 1133 // Request biased input stream | ||
832 | RPS_CS_DEBUG_STREAM_REPLY = 1134 // Send peer of biased stream | ||
833 | RPS_CS_DEBUG_STREAM_CANCEL = 1135 // Cancel getting biased stream | ||
834 | |||
835 | //------------------------------------------------------------------ | ||
836 | // CATCH-ALL_DEBUG message | ||
837 | //------------------------------------------------------------------ | ||
838 | |||
839 | ALL = 65535 // Type used to match 'all' message types. | ||
840 | ) | ||
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 ( | |||
103 | // by the local peer. | 103 | // by the local peer. |
104 | type ResultFilter interface { | 104 | type ResultFilter interface { |
105 | 105 | ||
106 | // Add entry to filter | 106 | // Add block to filter |
107 | Add(Block) | 107 | Add(Block) |
108 | 108 | ||
109 | // Contains returns true if block is filtered | 109 | // Contains returns true if block is filtered |
110 | Contains(Block) bool | 110 | Contains(Block) bool |
111 | 111 | ||
112 | // ContainsHash returns true if block hash is filtered | 112 | // ContainsHash returns true if block hash is filtered |
113 | ContainsHash(bh *crypto.HashCode) bool | 113 | ContainsHash(*crypto.HashCode) bool |
114 | 114 | ||
115 | // Bytes returns the binary representation of a result filter | 115 | // Bytes returns the binary representation of a result filter |
116 | Bytes() []byte | 116 | Bytes() []byte |
@@ -141,18 +141,19 @@ func NewGenericResultFilter() *GenericResultFilter { | |||
141 | 141 | ||
142 | // Add a block to the result filter. | 142 | // Add a block to the result filter. |
143 | func (rf *GenericResultFilter) Add(b Block) { | 143 | func (rf *GenericResultFilter) Add(b Block) { |
144 | rf.bf.Add(b.Bytes()) | 144 | bh := crypto.Hash(b.Bytes()) |
145 | rf.bf.Add(bh.Data) | ||
145 | } | 146 | } |
146 | 147 | ||
147 | // Contains returns true if a block is filtered | 148 | // Contains returns true if a block is filtered |
148 | func (rf *GenericResultFilter) Contains(b Block) bool { | 149 | func (rf *GenericResultFilter) Contains(b Block) bool { |
149 | bh := crypto.Hash(b.Bytes()) | 150 | bh := crypto.Hash(b.Bytes()) |
150 | return rf.bf.Contains(bh.Bits) | 151 | return rf.bf.Contains(bh.Data) |
151 | } | 152 | } |
152 | 153 | ||
153 | // ContainsHash returns true if a block hash is filtered | 154 | // ContainsHash returns true if a block hash is filtered |
154 | func (rf *GenericResultFilter) ContainsHash(bh *crypto.HashCode) bool { | 155 | func (rf *GenericResultFilter) ContainsHash(bh *crypto.HashCode) bool { |
155 | return rf.bf.Contains(bh.Bits) | 156 | return rf.bf.Contains(bh.Data) |
156 | } | 157 | } |
157 | 158 | ||
158 | // Bytes returns the binary representation of a result filter | 159 | // 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 @@ | |||
19 | package blocks | 19 | package blocks |
20 | 20 | ||
21 | import ( | 21 | import ( |
22 | "encoding/hex" | ||
23 | "fmt" | 22 | "fmt" |
24 | "gnunet/crypto" | 23 | "gnunet/crypto" |
25 | "gnunet/enums" | 24 | "gnunet/enums" |
@@ -141,7 +140,7 @@ func (q *GenericQuery) Decrypt(b Block) error { | |||
141 | 140 | ||
142 | // String returns the human-readable representation of a block | 141 | // String returns the human-readable representation of a block |
143 | func (q *GenericQuery) String() string { | 142 | func (q *GenericQuery) String() string { |
144 | return fmt.Sprintf("GenericQuery{btype=%d,key=%s}", q.btype, hex.EncodeToString(q.Key().Bits)) | 143 | return fmt.Sprintf("GenericQuery{btype=%s,key=%s}", q.btype, q.Key().Short()) |
145 | } | 144 | } |
146 | 145 | ||
147 | // NewGenericQuery creates a simple Query from hash code. | 146 | // NewGenericQuery creates a simple Query from hash code. |
@@ -155,46 +154,73 @@ func NewGenericQuery(key *crypto.HashCode, btype enums.BlockType, flags uint16) | |||
155 | } | 154 | } |
156 | 155 | ||
157 | //---------------------------------------------------------------------- | 156 | //---------------------------------------------------------------------- |
157 | // Generic block (custom implementation unknown to gnunet-go) | ||
158 | //---------------------------------------------------------------------- | ||
158 | 159 | ||
159 | // GenericBlock is the block in simple binary representation | 160 | // GenericBlock is used for custom blocks not known to the DHT |
160 | type GenericBlock struct { | 161 | type GenericBlock struct { |
161 | block []byte // block data | 162 | BType enums.BlockType // block type |
162 | btype enums.BlockType // block type | 163 | Expire_ util.AbsoluteTime // expiration time |
163 | expire util.AbsoluteTime // expiration date | 164 | Data []byte // block data |
165 | } | ||
166 | |||
167 | // NewGenericBlock creates a custom block instance | ||
168 | func NewGenericBlock(btype enums.BlockType, expire util.AbsoluteTime, blk []byte) Block { | ||
169 | return &GenericBlock{ | ||
170 | BType: btype, | ||
171 | Expire_: expire, | ||
172 | Data: util.Clone(blk), | ||
173 | } | ||
164 | } | 174 | } |
165 | 175 | ||
166 | // Bytes returns the binary representation | 176 | // Bytes returns the DHT block data (unstructured without type and |
177 | // expiration information. | ||
167 | func (b *GenericBlock) Bytes() []byte { | 178 | func (b *GenericBlock) Bytes() []byte { |
168 | return b.block | 179 | return util.Clone(b.Data) |
169 | } | 180 | } |
170 | 181 | ||
171 | // Type returns the block type | 182 | // Return the block type |
172 | func (b *GenericBlock) Type() enums.BlockType { | 183 | func (b *GenericBlock) Type() enums.BlockType { |
173 | return b.btype | 184 | return b.BType |
174 | } | 185 | } |
175 | 186 | ||
176 | // Expire returns the block expiration | 187 | // Expire returns the block expiration (never for custom blocks) |
177 | func (b *GenericBlock) Expire() util.AbsoluteTime { | 188 | func (b *GenericBlock) Expire() util.AbsoluteTime { |
178 | return b.expire | 189 | return util.AbsoluteTimeNever() |
190 | } | ||
191 | |||
192 | // Verify the integrity of a block (optional). Override in custom query | ||
193 | // types to implement block-specific integrity checks (see GNSBlock for | ||
194 | // example). This verification is usually weaker than the verification | ||
195 | // method from a Query (see GNSBlock.Verify for explanation). | ||
196 | func (b *GenericBlock) Verify() (bool, error) { | ||
197 | return true, nil | ||
179 | } | 198 | } |
180 | 199 | ||
181 | // String returns the human-readable representation of a block | 200 | // String returns the human-readable representation of a block |
182 | func (b *GenericBlock) String() string { | 201 | func (b *GenericBlock) String() string { |
183 | return fmt.Sprintf("GenericBlock{type=%d,expires=%s,data=[%d]}", | 202 | return fmt.Sprintf("Block{type=%s,expire=%s,data=[%d]", b.BType, b.Expire_, len(b.Data)) |
184 | b.btype, b.expire.String(), len(b.block)) | ||
185 | } | 203 | } |
186 | 204 | ||
187 | // Verify interface method implementation | 205 | //---------------------------------------------------------------------- |
188 | func (b *GenericBlock) Verify() (bool, error) { | 206 | // Block factory: extend for custom block types |
189 | // no verification, no errors ;) | 207 | //---------------------------------------------------------------------- |
190 | return true, nil | 208 | |
191 | } | 209 | // Known block factories |
210 | var ( | ||
211 | blkFactory = map[enums.BlockType]func() Block{ | ||
212 | enums.BLOCK_TYPE_GNS_NAMERECORD: NewGNSBlock, | ||
213 | enums.BLOCK_TYPE_DHT_URL_HELLO: NewHelloBlock, | ||
214 | } | ||
215 | ) | ||
192 | 216 | ||
193 | // NewGenericBlock creates a Block from binary data. | 217 | // NewGenericBlock creates a Block from binary data. |
194 | func NewGenericBlock(buf []byte) *GenericBlock { | 218 | func NewBlock(btype enums.BlockType, expires util.AbsoluteTime, blk []byte) (b Block, err error) { |
195 | return &GenericBlock{ | 219 | fac, ok := blkFactory[btype] |
196 | block: util.Clone(buf), | 220 | if !ok { |
197 | btype: enums.BLOCK_TYPE_ANY, // unknown block type | 221 | return NewGenericBlock(btype, expires, blk), nil |
198 | expire: util.AbsoluteTimeNever(), // never expires | ||
199 | } | 222 | } |
223 | b = fac() | ||
224 | err = data.Unmarshal(b, blk) | ||
225 | return | ||
200 | } | 226 | } |
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 { | |||
128 | // An encrypted and signed container for GNS resource records that represents | 128 | // An encrypted and signed container for GNS resource records that represents |
129 | // the "atomic" data structure associated with a GNS label in a given zone. | 129 | // the "atomic" data structure associated with a GNS label in a given zone. |
130 | type GNSBlock struct { | 130 | type GNSBlock struct { |
131 | GenericBlock | ||
132 | 131 | ||
133 | // persistent | 132 | // persistent |
134 | DerivedKeySig *crypto.ZoneSignature // Derived key used for signing | 133 | DerivedKeySig *crypto.ZoneSignature // Derived key used for signing |
@@ -147,19 +146,28 @@ func (b *GNSBlock) Bytes() []byte { | |||
147 | return buf | 146 | return buf |
148 | } | 147 | } |
149 | 148 | ||
149 | // Expire returns the expiration date of the block. | ||
150 | func (b *GNSBlock) Expire() util.AbsoluteTime { | ||
151 | return b.Body.Expire | ||
152 | } | ||
153 | |||
154 | // Type returns the requested block type | ||
155 | func (b *GNSBlock) Type() enums.BlockType { | ||
156 | return enums.BLOCK_TYPE_GNS_NAMERECORD | ||
157 | } | ||
158 | |||
150 | // String returns the human-readable representation of a GNSBlock | 159 | // String returns the human-readable representation of a GNSBlock |
151 | func (b *GNSBlock) String() string { | 160 | func (b *GNSBlock) String() string { |
152 | return fmt.Sprintf("GNSBlock{Verified=%v,Decrypted=%v,data=[%d]}", | 161 | return fmt.Sprintf("GNSBlock{Verified=%v,Decrypted=%v,data=[%d]}", |
153 | b.verified, b.decrypted, len(b.Body.Data)) | 162 | b.verified, b.decrypted, len(b.Body.Data)) |
154 | } | 163 | } |
155 | 164 | ||
156 | // NewBlock instantiates an empty GNS block | 165 | // NewGNSBlock instantiates an empty GNS block |
157 | func NewBlock() *GNSBlock { | 166 | func NewGNSBlock() Block { |
158 | return &GNSBlock{ | 167 | return &GNSBlock{ |
159 | DerivedKeySig: nil, | 168 | DerivedKeySig: nil, |
160 | Body: &SignedGNSBlockData{ | 169 | Body: &SignedGNSBlockData{ |
161 | Purpose: new(crypto.SignaturePurpose), | 170 | Purpose: new(crypto.SignaturePurpose), |
162 | Expire: *new(util.AbsoluteTime), | ||
163 | Data: nil, | 171 | Data: nil, |
164 | }, | 172 | }, |
165 | checked: false, | 173 | 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/" | |||
57 | type HelloBlock struct { | 57 | type HelloBlock struct { |
58 | PeerID *util.PeerID `` // peer identifier | 58 | PeerID *util.PeerID `` // peer identifier |
59 | Signature *util.PeerSignature `` // signature | 59 | Signature *util.PeerSignature `` // signature |
60 | Expires util.AbsoluteTime `` // Expiration date | 60 | Expire_ util.AbsoluteTime `` // Expiration date |
61 | AddrBin []byte `size:"*"` // raw address data | 61 | AddrBin []byte `size:"*"` // raw address data |
62 | 62 | ||
63 | // transient attributes | 63 | // transient attributes |
64 | addrs []*util.Address // cooked address data | 64 | addrs []*util.Address // cooked address data |
65 | } | 65 | } |
66 | 66 | ||
67 | // NewHelloBlock initializes a new HELLO block (unsigned) | 67 | // NewHelloBlock initializes an empty HELLO block |
68 | func NewHelloBlock(peer *util.PeerID, addrs []*util.Address, ttl time.Duration) *HelloBlock { | 68 | func NewHelloBlock() Block { |
69 | return new(HelloBlock) | ||
70 | } | ||
71 | |||
72 | // InitHelloBlock initializes a new HELLO block (unsigned) | ||
73 | func InitHelloBlock(peer *util.PeerID, addrs []*util.Address, ttl time.Duration) *HelloBlock { | ||
69 | hb := new(HelloBlock) | 74 | hb := new(HelloBlock) |
70 | hb.PeerID = peer | 75 | hb.PeerID = peer |
71 | // limit expiration to second precision (HELLO-URL compatibility) | 76 | // limit expiration to second precision (HELLO-URL compatibility) |
72 | hb.Expires = util.NewAbsoluteTimeEpoch(uint64(time.Now().Add(ttl).Unix())) | 77 | hb.SetExpire(ttl) |
73 | hb.SetAddresses(addrs) | 78 | hb.SetAddresses(addrs) |
74 | return hb | 79 | return hb |
75 | } | 80 | } |
76 | 81 | ||
82 | func (h *HelloBlock) SetExpire(ttl time.Duration) { | ||
83 | h.Expire_ = util.NewAbsoluteTimeEpoch(uint64(time.Now().Add(ttl).Unix())) | ||
84 | } | ||
85 | |||
77 | // SetAddresses adds a bulk of addresses for this HELLO block. | 86 | // SetAddresses adds a bulk of addresses for this HELLO block. |
78 | func (h *HelloBlock) SetAddresses(a []*util.Address) { | 87 | func (h *HelloBlock) SetAddresses(a []*util.Address) { |
79 | if len(a) == 0 { | 88 | if len(a) == 0 { |
@@ -87,6 +96,9 @@ func (h *HelloBlock) SetAddresses(a []*util.Address) { | |||
87 | 96 | ||
88 | // Addresses returns the list of addresses | 97 | // Addresses returns the list of addresses |
89 | func (h *HelloBlock) Addresses() []*util.Address { | 98 | func (h *HelloBlock) Addresses() []*util.Address { |
99 | if h.addrs == nil { | ||
100 | h.finalize() | ||
101 | } | ||
90 | return util.Clone(h.addrs) | 102 | return util.Clone(h.addrs) |
91 | } | 103 | } |
92 | 104 | ||
@@ -132,8 +144,8 @@ func ParseHelloBlockFromURL(u string, checkExpiry bool) (h *HelloBlock, err erro | |||
132 | if exp, err = strconv.ParseUint(q[0], 10, 64); err != nil { | 144 | if exp, err = strconv.ParseUint(q[0], 10, 64); err != nil { |
133 | return | 145 | return |
134 | } | 146 | } |
135 | h.Expires = util.NewAbsoluteTimeEpoch(exp) | 147 | h.Expire_ = util.NewAbsoluteTimeEpoch(exp) |
136 | if checkExpiry && h.Expires.Expired() { | 148 | if checkExpiry && h.Expire_.Expired() { |
137 | err = ErrHelloExpired | 149 | err = ErrHelloExpired |
138 | return | 150 | return |
139 | } | 151 | } |
@@ -228,13 +240,13 @@ func (h *HelloBlock) Bytes() []byte { | |||
228 | 240 | ||
229 | // Expire returns the block expiration | 241 | // Expire returns the block expiration |
230 | func (h *HelloBlock) Expire() util.AbsoluteTime { | 242 | func (h *HelloBlock) Expire() util.AbsoluteTime { |
231 | return h.Expires | 243 | return h.Expire_ |
232 | } | 244 | } |
233 | 245 | ||
234 | // String returns the human-readable representation of a block | 246 | // String returns the human-readable representation of a block |
235 | func (h *HelloBlock) String() string { | 247 | func (h *HelloBlock) String() string { |
236 | return fmt.Sprintf("HelloBlock{peer=%s,expires=%s,addrs=[%d]}", | 248 | return fmt.Sprintf("HelloBlock{peer=%s,expires=%s,addrs=[%d]}", |
237 | h.PeerID, h.Expires, len(h.Addresses())) | 249 | h.PeerID, h.Expire_, len(h.Addresses())) |
238 | } | 250 | } |
239 | 251 | ||
240 | // URL returns the HELLO URL for the data. | 252 | // URL returns the HELLO URL for the data. |
@@ -243,7 +255,7 @@ func (h *HelloBlock) URL() string { | |||
243 | helloPrefix, | 255 | helloPrefix, |
244 | h.PeerID.String(), | 256 | h.PeerID.String(), |
245 | util.EncodeBinaryToString(h.Signature.Data), | 257 | util.EncodeBinaryToString(h.Signature.Data), |
246 | h.Expires.Epoch(), | 258 | h.Expire_.Epoch(), |
247 | ) | 259 | ) |
248 | for i, a := range h.addrs { | 260 | for i, a := range h.addrs { |
249 | if i > 0 { | 261 | if i > 0 { |
@@ -256,16 +268,16 @@ func (h *HelloBlock) URL() string { | |||
256 | return u | 268 | return u |
257 | } | 269 | } |
258 | 270 | ||
259 | // Equals returns true if two HELLOs are the same. The expiration | 271 | // Equal returns true if two HELLOs are the same. The expiration |
260 | // timestamp is ignored in the comparison. | 272 | // timestamp is ignored in the comparison. |
261 | func (h *HelloBlock) Equals(g *HelloBlock) bool { | 273 | func (h *HelloBlock) Equal(g *HelloBlock) bool { |
262 | if !h.PeerID.Equals(g.PeerID) || | 274 | if !h.PeerID.Equal(g.PeerID) || |
263 | !util.Equals(h.Signature.Data, g.Signature.Data) || | 275 | !util.Equal(h.Signature.Data, g.Signature.Data) || |
264 | len(h.addrs) != len(g.addrs) { | 276 | len(h.addrs) != len(g.addrs) { |
265 | return false | 277 | return false |
266 | } | 278 | } |
267 | for i, a := range h.addrs { | 279 | for i, a := range h.addrs { |
268 | if !a.Equals(g.addrs[i]) { | 280 | if !a.Equal(g.addrs[i]) { |
269 | return false | 281 | return false |
270 | } | 282 | } |
271 | } | 283 | } |
@@ -303,7 +315,7 @@ func (h *HelloBlock) SignedData() []byte { | |||
303 | err := binary.Write(buf, binary.BigEndian, size) | 315 | err := binary.Write(buf, binary.BigEndian, size) |
304 | if err == nil { | 316 | if err == nil { |
305 | if err = binary.Write(buf, binary.BigEndian, purpose); err == nil { | 317 | if err = binary.Write(buf, binary.BigEndian, purpose); err == nil { |
306 | if err = binary.Write(buf, binary.BigEndian, h.Expires /*.Epoch()*1000000*/); err == nil { | 318 | if err = binary.Write(buf, binary.BigEndian, h.Expire_); err == nil { |
307 | if n, err = buf.Write(hAddr[:]); err == nil { | 319 | if n, err = buf.Write(hAddr[:]); err == nil { |
308 | if n != len(hAddr[:]) { | 320 | if n != len(hAddr[:]) { |
309 | err = errors.New("signed data size mismatch") | 321 | err = errors.New("signed data size mismatch") |
@@ -346,7 +358,7 @@ func (bh *HelloBlockHandler) ValidateBlockKey(b Block, key *crypto.HashCode) boo | |||
346 | logger.Println(logger.WARN, "[HelloHdlr] ValidateBlockKey: not a HELLO block") | 358 | logger.Println(logger.WARN, "[HelloHdlr] ValidateBlockKey: not a HELLO block") |
347 | return false | 359 | return false |
348 | } | 360 | } |
349 | return key.Equals(bkey) | 361 | return key.Equal(bkey) |
350 | } | 362 | } |
351 | 363 | ||
352 | // DeriveBlockKey is used to synthesize the block key from the block | 364 | // DeriveBlockKey is used to synthesize the block key from the block |
@@ -473,7 +485,7 @@ func (rf *HelloResultFilter) Contains(b Block) bool { | |||
473 | 485 | ||
474 | // ContainsHash checks if a block hash is contained in the result filter | 486 | // ContainsHash checks if a block hash is contained in the result filter |
475 | func (rf *HelloResultFilter) ContainsHash(bh *crypto.HashCode) bool { | 487 | func (rf *HelloResultFilter) ContainsHash(bh *crypto.HashCode) bool { |
476 | return rf.bf.Contains(bh.Bits) | 488 | return rf.bf.Contains(bh.Data) |
477 | } | 489 | } |
478 | 490 | ||
479 | // Bytes returns a binary representation of a HELLO result filter | 491 | // 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) { | |||
64 | } | 64 | } |
65 | 65 | ||
66 | // create new HELLO block | 66 | // create new HELLO block |
67 | block = NewHelloBlock(peer, addrList, time.Hour) | 67 | block = InitHelloBlock(peer, addrList, time.Hour) |
68 | 68 | ||
69 | // sign block. | 69 | // sign block. |
70 | sig, err := sk.EdSign(block.SignedData()) | 70 | sig, err := sk.EdSign(block.SignedData()) |
@@ -144,8 +144,8 @@ func TestHelloDebug(t *testing.T) { | |||
144 | t.Log("Block: " + hex.EncodeToString(buf)) | 144 | t.Log("Block: " + hex.EncodeToString(buf)) |
145 | t.Log("PeerID: " + hb.PeerID.String()) | 145 | t.Log("PeerID: " + hb.PeerID.String()) |
146 | t.Log(" -> " + hex.EncodeToString(hb.PeerID.Bytes())) | 146 | t.Log(" -> " + hex.EncodeToString(hb.PeerID.Bytes())) |
147 | t.Logf("Expire: %d", hb.Expires.Val) | 147 | t.Logf("Expire: %d", hb.Expire_.Val) |
148 | t.Logf(" -> " + hb.Expires.String()) | 148 | t.Logf(" -> " + hb.Expire_.String()) |
149 | var exp util.AbsoluteTime | 149 | var exp util.AbsoluteTime |
150 | if err = data.Unmarshal(&exp, buf[32:40]); err != nil { | 150 | if err = data.Unmarshal(&exp, buf[32:40]); err != nil { |
151 | t.Fatal(err) | 151 | 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 ( | |||
31 | func (m *Module) lookupHelloCache(label string, addr *PeerAddress, rf blocks.ResultFilter, approx bool) (results []*store.DHTResult) { | 31 | func (m *Module) lookupHelloCache(label string, addr *PeerAddress, rf blocks.ResultFilter, approx bool) (results []*store.DHTResult) { |
32 | logger.Printf(logger.DBG, "[%s] GET message for HELLO: check cache", label) | 32 | logger.Printf(logger.DBG, "[%s] GET message for HELLO: check cache", label) |
33 | // find best cached HELLO | 33 | // find best cached HELLO |
34 | return m.rtable.LookupHello(addr, rf, approx) | 34 | return m.rtable.LookupHello(addr, rf, approx, label) |
35 | } | 35 | } |
36 | 36 | ||
37 | // getLocalStorage tries to find the requested block in local storage | 37 | // 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 | |||
20 | 20 | ||
21 | import ( | 21 | import ( |
22 | "context" | 22 | "context" |
23 | "gnunet/core" | ||
23 | "gnunet/crypto" | 24 | "gnunet/crypto" |
24 | "gnunet/enums" | 25 | "gnunet/enums" |
25 | "gnunet/message" | 26 | "gnunet/message" |
@@ -42,20 +43,13 @@ import ( | |||
42 | func (m *Module) HandleMessage(ctx context.Context, sender *util.PeerID, msgIn message.Message, back transport.Responder) bool { | 43 | func (m *Module) HandleMessage(ctx context.Context, sender *util.PeerID, msgIn message.Message, back transport.Responder) bool { |
43 | // assemble log label | 44 | // assemble log label |
44 | label := "dht" | 45 | label := "dht" |
45 | if v := ctx.Value("label"); v != nil { | 46 | if v := ctx.Value(core.CtxKey("label")); v != nil { |
46 | if s, ok := v.(string); ok && len(s) > 0 { | 47 | if s, ok := v.(string); ok && len(s) > 0 { |
47 | label = "dht-" + s | 48 | label = s |
48 | } | 49 | } |
49 | } | 50 | } |
50 | logger.Printf(logger.INFO, "[%s] message received from %s", label, sender) | ||
51 | local := m.core.PeerID() | 51 | local := m.core.PeerID() |
52 | 52 | ||
53 | // check for local message | ||
54 | if sender.Equals(local) { | ||
55 | logger.Printf(logger.WARN, "[%s] dropping local message received: %s", label, util.Dump(msgIn, "json")) | ||
56 | return false | ||
57 | } | ||
58 | |||
59 | // process message | 53 | // process message |
60 | switch msg := msgIn.(type) { | 54 | switch msg := msgIn.(type) { |
61 | 55 | ||
@@ -66,10 +60,11 @@ func (m *Module) HandleMessage(ctx context.Context, sender *util.PeerID, msgIn m | |||
66 | //-------------------------------------------------------------- | 60 | //-------------------------------------------------------------- |
67 | // DHT-P2P GET | 61 | // DHT-P2P GET |
68 | //-------------------------------------------------------------- | 62 | //-------------------------------------------------------------- |
69 | logger.Printf(logger.INFO, "[%s] Handling DHT-P2P-GET message", label) | 63 | logger.Printf(logger.INFO, "[%s] DHT-P2P-GET from %s (type %s, flags=%s)", |
64 | label, sender.Short(), msg.BType, message.DHTFlags(msg.Flags)) | ||
70 | 65 | ||
71 | // assemble query and initialize (cache) results | 66 | // assemble query and initialize (cache) results |
72 | query := blocks.NewGenericQuery(msg.Query, enums.BlockType(msg.BType), msg.Flags) | 67 | query := blocks.NewGenericQuery(msg.Query, msg.BType, msg.Flags) |
73 | var results []*store.DHTResult | 68 | var results []*store.DHTResult |
74 | 69 | ||
75 | //-------------------------------------------------------------- | 70 | //-------------------------------------------------------------- |
@@ -79,7 +74,7 @@ func (m *Module) HandleMessage(ctx context.Context, sender *util.PeerID, msgIn m | |||
79 | if ok { | 74 | if ok { |
80 | // validate block query | 75 | // validate block query |
81 | if !blockHdlr.ValidateBlockQuery(msg.Query, msg.XQuery) { | 76 | if !blockHdlr.ValidateBlockQuery(msg.Query, msg.XQuery) { |
82 | logger.Printf(logger.WARN, "[%s] DHT-P2P-GET invalid query -- discarded", label) | 77 | logger.Printf(logger.WARN, "[%s] invalid query -- discarded", label) |
83 | return false | 78 | return false |
84 | } | 79 | } |
85 | } else { | 80 | } else { |
@@ -114,14 +109,19 @@ func (m *Module) HandleMessage(ctx context.Context, sender *util.PeerID, msgIn m | |||
114 | //---------------------------------------------------------- | 109 | //---------------------------------------------------------- |
115 | // check if we need to respond (and how) (9.4.3.3) | 110 | // check if we need to respond (and how) (9.4.3.3) |
116 | addr := NewQueryAddress(query.Key()) | 111 | addr := NewQueryAddress(query.Key()) |
117 | closest := m.rtable.IsClosestPeer(nil, addr, msg.PeerFilter, 0) | ||
118 | demux := int(msg.Flags)&enums.DHT_RO_DEMULTIPLEX_EVERYWHERE != 0 | 112 | demux := int(msg.Flags)&enums.DHT_RO_DEMULTIPLEX_EVERYWHERE != 0 |
119 | approx := int(msg.Flags)&enums.DHT_RO_FIND_APPROXIMATE != 0 | 113 | approx := int(msg.Flags)&enums.DHT_RO_FIND_APPROXIMATE != 0 |
120 | 114 | closest := false | |
115 | // only check for closest node if we are not looking for our own HELLO | ||
116 | if msg.Flags&enums.DHT_RO_DISCOVERY == 0 { | ||
117 | closest = m.rtable.IsClosestPeer(nil, addr, msg.PeerFilter, 0) | ||
118 | } else { | ||
119 | // remove discovery flag | ||
120 | msg.Flags &^= enums.DHT_RO_DISCOVERY | ||
121 | } | ||
121 | // enforced actions | 122 | // enforced actions |
122 | doResult := closest || (demux && approx) | 123 | doResult, doForward := getActions(closest, demux, approx) |
123 | doForward := !closest || (demux && !approx) | 124 | logger.Printf(logger.DBG, "[%s] Actions: closest=%v, demux=%v, approx=%v --> result=%v, forward=%v", |
124 | logger.Printf(logger.DBG, "[%s] GET message: closest=%v, demux=%v, approx=%v --> result=%v, forward=%v", | ||
125 | label, closest, demux, approx, doResult, doForward) | 125 | label, closest, demux, approx, doResult, doForward) |
126 | 126 | ||
127 | //------------------------------------------------------ | 127 | //------------------------------------------------------ |
@@ -144,7 +144,11 @@ func (m *Module) HandleMessage(ctx context.Context, sender *util.PeerID, msgIn m | |||
144 | results = append(results, lclResults...) | 144 | results = append(results, lclResults...) |
145 | } | 145 | } |
146 | } | 146 | } |
147 | // if we have results, send them as response | 147 | // if we have results, send them as response on the back channel |
148 | rcv := "locally" | ||
149 | if back.Receiver() != nil { | ||
150 | rcv = back.Receiver().Short() | ||
151 | } | ||
148 | for _, result := range results { | 152 | for _, result := range results { |
149 | var pth *path.Path | 153 | var pth *path.Path |
150 | // check if record the route | 154 | // check if record the route |
@@ -156,9 +160,9 @@ func (m *Module) HandleMessage(ctx context.Context, sender *util.PeerID, msgIn m | |||
156 | pth.Add(pe) | 160 | pth.Add(pe) |
157 | } | 161 | } |
158 | 162 | ||
159 | logger.Printf(logger.INFO, "[%s] sending DHT result message to caller", label) | 163 | logger.Printf(logger.INFO, "[%s] sending result message to %s", label, rcv) |
160 | if err := m.sendResult(ctx, query, result.Entry.Blk, pth, back); err != nil { | 164 | if err := m.sendResult(ctx, query, result.Entry.Blk, pth, back); err != nil { |
161 | logger.Printf(logger.ERROR, "[%s] Failed to send DHT result message: %s", label, err.Error()) | 165 | logger.Printf(logger.ERROR, "[%s] Failed to send result message: %s", label, err.Error()) |
162 | } | 166 | } |
163 | } | 167 | } |
164 | } | 168 | } |
@@ -174,21 +178,22 @@ func (m *Module) HandleMessage(ctx context.Context, sender *util.PeerID, msgIn m | |||
174 | for n := 0; n < numForward; n++ { | 178 | for n := 0; n < numForward; n++ { |
175 | if p := m.rtable.SelectClosestPeer(addr, pf, 0); p != nil { | 179 | if p := m.rtable.SelectClosestPeer(addr, pf, 0); p != nil { |
176 | // forward message to peer | 180 | // forward message to peer |
177 | logger.Printf(logger.INFO, "[%s] forward DHT get message to %s", label, p.String()) | 181 | logger.Printf(logger.INFO, "[%s] forward GET message to %s", label, p.Peer.Short()) |
178 | if err := back.Send(ctx, msgOut); err != nil { | 182 | if err := m.core.Send(ctx, p.Peer, msgOut); err != nil { |
179 | logger.Printf(logger.ERROR, "[%s] Failed to forward DHT get message: %s", label, err.Error()) | 183 | logger.Printf(logger.ERROR, "[%s] Failed to forward GET message: %s", label, err.Error()) |
180 | } | 184 | } |
181 | pf.Add(p.Peer) | 185 | pf.Add(p.Peer) |
182 | // create open get-forward result handler | 186 | // create open get-forward result handler |
183 | rh := NewForwardResultHandler(msg, rf, back) | 187 | rh := NewResultHandler(msg, rf, back) |
184 | logger.Printf(logger.INFO, "[%s] DHT-P2P-GET task #%d (%s) started", label, rh.ID(), rh.Key()) | 188 | logger.Printf(logger.INFO, "[%s] result handler task #%d (key %s) started", |
189 | label, rh.ID(), rh.Key().Short()) | ||
185 | m.reshdlrs.Add(rh) | 190 | m.reshdlrs.Add(rh) |
186 | } else { | 191 | } else { |
187 | break | 192 | break |
188 | } | 193 | } |
189 | } | 194 | } |
190 | } | 195 | } |
191 | logger.Printf(logger.INFO, "[%s] Handling DHT-P2P-GET message done", label) | 196 | logger.Printf(logger.INFO, "[%s] DHT-P2P-GET done", label) |
192 | 197 | ||
193 | //================================================================== | 198 | //================================================================== |
194 | // DHT-P2P-PUT | 199 | // DHT-P2P-PUT |
@@ -197,41 +202,46 @@ func (m *Module) HandleMessage(ctx context.Context, sender *util.PeerID, msgIn m | |||
197 | //---------------------------------------------------------- | 202 | //---------------------------------------------------------- |
198 | // DHT-P2P PUT | 203 | // DHT-P2P PUT |
199 | //---------------------------------------------------------- | 204 | //---------------------------------------------------------- |
200 | logger.Printf(logger.INFO, "[%s] Handling DHT-P2P-PUT message", label) | 205 | logger.Printf(logger.INFO, "[%s] DHT-P2P-PUT from %s (type %s, flags=%s)", |
206 | label, sender.Short(), msg.BType, message.DHTFlags(msg.Flags)) | ||
201 | 207 | ||
202 | // assemble query and entry | 208 | // assemble query and entry |
203 | query := blocks.NewGenericQuery(msg.Key, enums.BlockType(msg.BType), msg.Flags) | 209 | query := blocks.NewGenericQuery(msg.Key, msg.BType, msg.Flags) |
210 | blk, err := blocks.NewBlock(msg.BType, msg.Expire, msg.Block) | ||
211 | if err != nil { | ||
212 | logger.Printf(logger.ERROR, "[%s] message block problem: %s", label, err.Error()) | ||
213 | return false | ||
214 | } | ||
204 | entry := &store.DHTEntry{ | 215 | entry := &store.DHTEntry{ |
205 | Blk: blocks.NewGenericBlock(msg.Block), | 216 | Blk: blk, |
206 | Path: nil, | 217 | Path: nil, |
207 | } | 218 | } |
208 | 219 | ||
209 | //-------------------------------------------------------------- | 220 | //-------------------------------------------------------------- |
210 | // check if request is expired (9.3.2.1) | 221 | // check if request is expired (9.3.2.1) |
211 | if msg.Expiration.Expired() { | 222 | if msg.Expire.Expired() { |
212 | logger.Printf(logger.WARN, "[%s] DHT-P2P-PUT message expired (%s)", label, msg.Expiration.String()) | 223 | logger.Printf(logger.WARN, "[%s] PUT message expired (%s) -- ignored", label, msg.Expire) |
213 | return false | 224 | return false |
214 | } | 225 | } |
215 | btype := enums.BlockType(msg.BType) | 226 | blockHdlr, ok := blocks.BlockHandlers[msg.BType] |
216 | blockHdlr, ok := blocks.BlockHandlers[btype] | ||
217 | if ok { // (9.3.2.2) | 227 | if ok { // (9.3.2.2) |
218 | // reconstruct block instance | 228 | // reconstruct block instance |
219 | if block, err := blockHdlr.ParseBlock(msg.Block); err == nil { | 229 | if block, err := blockHdlr.ParseBlock(msg.Block); err == nil { |
220 | 230 | ||
221 | // validate block key (9.3.2.3) | 231 | // validate block key (9.3.2.3) |
222 | if !blockHdlr.ValidateBlockKey(block, msg.Key) { | 232 | if !blockHdlr.ValidateBlockKey(block, msg.Key) { |
223 | logger.Printf(logger.WARN, "[%s] DHT-P2P-PUT invalid key -- discarded", label) | 233 | logger.Printf(logger.WARN, "[%s] PUT invalid key -- discarded", label) |
224 | return false | 234 | return false |
225 | } | 235 | } |
226 | 236 | ||
227 | // validate block payload (9.3.2.4) | 237 | // validate block payload (9.3.2.4) |
228 | if !blockHdlr.ValidateBlockStoreRequest(block) { | 238 | if !blockHdlr.ValidateBlockStoreRequest(block) { |
229 | logger.Printf(logger.WARN, "[%s] DHT-P2P-PUT invalid payload -- discarded", label) | 239 | logger.Printf(logger.WARN, "[%s] PUT invalid payload -- discarded", label) |
230 | return false | 240 | return false |
231 | } | 241 | } |
232 | } | 242 | } |
233 | } else { | 243 | } else { |
234 | logger.Printf(logger.INFO, "[%s] No validator defined for block type %s", label, btype.String()) | 244 | logger.Printf(logger.INFO, "[%s] No validator defined for block type %s", label, msg.BType) |
235 | blockHdlr = nil | 245 | blockHdlr = nil |
236 | } | 246 | } |
237 | // clone peer filter | 247 | // clone peer filter |
@@ -242,7 +252,9 @@ func (m *Module) HandleMessage(ctx context.Context, sender *util.PeerID, msgIn m | |||
242 | addr := NewQueryAddress(msg.Key) | 252 | addr := NewQueryAddress(msg.Key) |
243 | closest := m.rtable.IsClosestPeer(nil, addr, msg.PeerFilter, 0) | 253 | closest := m.rtable.IsClosestPeer(nil, addr, msg.PeerFilter, 0) |
244 | demux := int(msg.Flags)&enums.DHT_RO_DEMULTIPLEX_EVERYWHERE != 0 | 254 | demux := int(msg.Flags)&enums.DHT_RO_DEMULTIPLEX_EVERYWHERE != 0 |
245 | logger.Printf(logger.DBG, "[%s] PUT message: closest=%v, demux=%v", label, closest, demux) | 255 | doStore, doForward := putActions(closest, demux) |
256 | logger.Printf(logger.DBG, "[%s] Actions: closest=%v, demux=%v => doStore=%v, doForward=%v", | ||
257 | label, closest, demux, doStore, doForward) | ||
246 | 258 | ||
247 | //-------------------------------------------------------------- | 259 | //-------------------------------------------------------------- |
248 | // check if sender is in peer filter (9.3.2.5) | 260 | // 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 | |||
259 | 271 | ||
260 | //-------------------------------------------------------------- | 272 | //-------------------------------------------------------------- |
261 | // store locally if we are closest peer or demux is set (9.3.2.8) | 273 | // store locally if we are closest peer or demux is set (9.3.2.8) |
262 | if closest || demux { | 274 | if doStore { |
263 | // store in local storage | 275 | // store in local storage |
264 | if err := m.store.Put(query, entry); err != nil { | 276 | if err := m.store.Put(query, entry); err != nil { |
265 | logger.Printf(logger.ERROR, "[%s] failed to store DHT entry: %s", label, err.Error()) | 277 | 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 | |||
268 | //-------------------------------------------------------------- | 280 | //-------------------------------------------------------------- |
269 | // if the put is for a HELLO block, add the sender to the | 281 | // if the put is for a HELLO block, add the sender to the |
270 | // routing table (9.3.2.9) | 282 | // routing table (9.3.2.9) |
271 | if btype == enums.BLOCK_TYPE_DHT_HELLO { | 283 | if msg.BType == enums.BLOCK_TYPE_DHT_HELLO { |
272 | // get addresses from HELLO block | 284 | // get addresses from HELLO block |
273 | hello, err := blocks.ParseHelloBlockFromBytes(msg.Block) | 285 | hello, err := blocks.ParseHelloBlockFromBytes(msg.Block) |
274 | if err != nil { | 286 | if err != nil { |
@@ -290,7 +302,7 @@ func (m *Module) HandleMessage(ctx context.Context, sender *util.PeerID, msgIn m | |||
290 | } | 302 | } |
291 | //-------------------------------------------------------------- | 303 | //-------------------------------------------------------------- |
292 | // check if we need to forward | 304 | // check if we need to forward |
293 | if !closest || demux { | 305 | if doForward { |
294 | // add local node to filter | 306 | // add local node to filter |
295 | pf.Add(local) | 307 | pf.Add(local) |
296 | 308 | ||
@@ -310,9 +322,9 @@ func (m *Module) HandleMessage(ctx context.Context, sender *util.PeerID, msgIn m | |||
310 | msgOut := msg.Update(pp, pf, msg.HopCount+1) | 322 | msgOut := msg.Update(pp, pf, msg.HopCount+1) |
311 | 323 | ||
312 | // forward message to peer | 324 | // forward message to peer |
313 | logger.Printf(logger.INFO, "[%s] forward DHT put message to %s", label, p.String()) | 325 | logger.Printf(logger.INFO, "[%s] forward PUT message to %s", label, p.Peer.Short()) |
314 | if err := back.Send(ctx, msgOut); err != nil { | 326 | if err := m.core.Send(ctx, p.Peer, msgOut); err != nil { |
315 | logger.Printf(logger.ERROR, "[%s] Failed to forward DHT put message: %s", label, err.Error()) | 327 | logger.Printf(logger.ERROR, "[%s] Failed to forward PUT message: %s", label, err.Error()) |
316 | } | 328 | } |
317 | // add forward node to filter | 329 | // add forward node to filter |
318 | pf.Add(p.Peer) | 330 | pf.Add(p.Peer) |
@@ -321,7 +333,7 @@ func (m *Module) HandleMessage(ctx context.Context, sender *util.PeerID, msgIn m | |||
321 | } | 333 | } |
322 | } | 334 | } |
323 | } | 335 | } |
324 | logger.Printf(logger.INFO, "[%s] Handling DHT-P2P-PUT message done", label) | 336 | logger.Printf(logger.INFO, "[%s] DHT-P2P-PUT done", label) |
325 | 337 | ||
326 | //================================================================== | 338 | //================================================================== |
327 | // DHT-P2P-RESULT | 339 | // DHT-P2P-RESULT |
@@ -330,14 +342,14 @@ func (m *Module) HandleMessage(ctx context.Context, sender *util.PeerID, msgIn m | |||
330 | //---------------------------------------------------------- | 342 | //---------------------------------------------------------- |
331 | // DHT-P2P RESULT | 343 | // DHT-P2P RESULT |
332 | //---------------------------------------------------------- | 344 | //---------------------------------------------------------- |
333 | logger.Printf(logger.INFO, "[%s] Handling DHT-P2P-RESULT message for type %s", | 345 | logger.Printf(logger.INFO, "[%s] DHT-P2P-RESULT from %s (type %s, flags=%s)", |
334 | label, enums.BlockType(msg.BType).String()) | 346 | label, sender.Short(), msg.BType, message.DHTFlags(msg.Flags)) |
335 | 347 | ||
336 | //-------------------------------------------------------------- | 348 | //-------------------------------------------------------------- |
337 | // check if request is expired (9.5.2.1) | 349 | // check if request is expired (9.5.2.1) |
338 | if msg.Expires.Expired() { | 350 | if msg.Expire.Expired() { |
339 | logger.Printf(logger.WARN, "[%s] DHT-P2P-RESULT message expired (%s)", | 351 | logger.Printf(logger.WARN, "[%s] message expired (%s) -- ignoring", |
340 | label, msg.Expires.String()) | 352 | label, msg.Expire.String()) |
341 | return false | 353 | return false |
342 | } | 354 | } |
343 | //-------------------------------------------------------------- | 355 | //-------------------------------------------------------------- |
@@ -349,7 +361,7 @@ func (m *Module) HandleMessage(ctx context.Context, sender *util.PeerID, msgIn m | |||
349 | if block, err := blockHdlr.ParseBlock(msg.Block); err == nil { | 361 | if block, err := blockHdlr.ParseBlock(msg.Block); err == nil { |
350 | // validate block (9.5.2.2) | 362 | // validate block (9.5.2.2) |
351 | if !blockHdlr.ValidateBlockStoreRequest(block) { | 363 | if !blockHdlr.ValidateBlockStoreRequest(block) { |
352 | logger.Printf(logger.WARN, "[%s] DHT-P2P-RESULT invalid block -- discarded", label) | 364 | logger.Printf(logger.WARN, "[%s] RESULT invalid block -- discarded", label) |
353 | return false | 365 | return false |
354 | } | 366 | } |
355 | // Compute block key (9.5.2.4) | 367 | // Compute block key (9.5.2.4) |
@@ -390,19 +402,19 @@ func (m *Module) HandleMessage(ctx context.Context, sender *util.PeerID, msgIn m | |||
390 | } | 402 | } |
391 | } | 403 | } |
392 | // message forwarding to responder | 404 | // message forwarding to responder |
393 | key := msg.Query.String() | 405 | logger.Printf(logger.DBG, "[%s] result key = %s", label, msg.Query.Short()) |
394 | logger.Printf(logger.DBG, "[%s] DHT-P2P-RESULT key = %s", label, key) | ||
395 | handled := false | 406 | handled := false |
407 | key := msg.Query.String() | ||
396 | if list, ok := m.reshdlrs.Get(key); ok { | 408 | if list, ok := m.reshdlrs.Get(key); ok { |
397 | for _, rh := range list { | 409 | for _, rh := range list { |
398 | logger.Printf(logger.DBG, "[%s] Task #%d for DHT-P2P-RESULT found", label, rh.ID()) | 410 | logger.Printf(logger.DBG, "[%s] Result handler task #%d found", label, rh.ID()) |
399 | 411 | ||
400 | //-------------------------------------------------------------- | 412 | //-------------------------------------------------------------- |
401 | // check task list for handler (9.5.2.6) | 413 | // check task list for handler (9.5.2.6) |
402 | if rh.Flags()&enums.DHT_RO_FIND_APPROXIMATE == 0 && blkKey != nil && !blkKey.Equals(rh.Key()) { | 414 | if rh.Flags()&enums.DHT_RO_FIND_APPROXIMATE == 0 && blkKey != nil && !blkKey.Equal(rh.Key()) { |
403 | // (9.5.2.6.a) derived key mismatch | 415 | // (9.5.2.6.a) derived key mismatch |
404 | logger.Printf(logger.ERROR, "[%s] derived block key / query key mismatch:", label) | 416 | logger.Printf(logger.ERROR, "[%s] derived block key / query key mismatch:", label) |
405 | logger.Printf(logger.ERROR, "[%s] --> %s != %s", label, blkKey.String(), rh.Key().String()) | 417 | logger.Printf(logger.ERROR, "[%s] --> %s != %s", label, blkKey, rh.Key()) |
406 | return false | 418 | return false |
407 | } | 419 | } |
408 | // (9.5.2.6.b+c) check block against query | 420 | // (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 | |||
419 | } | 431 | } |
420 | } | 432 | } |
421 | if !handled { | 433 | if !handled { |
422 | logger.Printf(logger.WARN, "[%s] DHT-P2P-RESULT not processed (no handler)", label) | 434 | logger.Printf(logger.WARN, "[%s] RESULT not processed (no handler)", label) |
435 | } else { | ||
436 | logger.Printf(logger.INFO, "[%s] DHT-P2P-RESULT done", label) | ||
423 | } | 437 | } |
424 | logger.Printf(logger.INFO, "[%s] Handling DHT-P2P-RESULT message done", label) | ||
425 | return handled | 438 | return handled |
426 | 439 | ||
427 | //================================================================== | 440 | //================================================================== |
@@ -431,11 +444,11 @@ func (m *Module) HandleMessage(ctx context.Context, sender *util.PeerID, msgIn m | |||
431 | //---------------------------------------------------------- | 444 | //---------------------------------------------------------- |
432 | // DHT-P2P HELLO | 445 | // DHT-P2P HELLO |
433 | //---------------------------------------------------------- | 446 | //---------------------------------------------------------- |
434 | logger.Printf(logger.INFO, "[%s] Handling DHT-P2P-HELLO message", label) | 447 | logger.Printf(logger.INFO, "[%s] DHT-P2P-HELLO from %s", label, sender.Short()) |
435 | 448 | ||
436 | // verify integrity of message | 449 | // verify integrity of message |
437 | if ok, err := msg.Verify(sender); !ok || err != nil { | 450 | if ok, err := msg.Verify(sender); !ok || err != nil { |
438 | logger.Printf(logger.WARN, "[%s] Received invalid DHT_P2P_HELLO message", label) | 451 | logger.Printf(logger.WARN, "[%s] Received invalid HELLO message", label) |
439 | if err != nil { | 452 | if err != nil { |
440 | logger.Printf(logger.ERROR, "[%s] --> %s", label, err.Error()) | 453 | logger.Printf(logger.ERROR, "[%s] --> %s", label, err.Error()) |
441 | } | 454 | } |
@@ -444,20 +457,20 @@ func (m *Module) HandleMessage(ctx context.Context, sender *util.PeerID, msgIn m | |||
444 | // keep peer addresses in core for transports | 457 | // keep peer addresses in core for transports |
445 | aList, err := msg.Addresses() | 458 | aList, err := msg.Addresses() |
446 | if err != nil { | 459 | if err != nil { |
447 | logger.Printf(logger.ERROR, "[%s] Failed to parse addresses from DHT_P2P_HELLO message", label) | 460 | logger.Printf(logger.ERROR, "[%s] Failed to parse addresses from HELLO message", label) |
448 | return false | 461 | return false |
449 | } | 462 | } |
450 | if newPeer := m.core.Learn(ctx, sender, aList); newPeer { | 463 | if newPeer := m.core.Learn(ctx, sender, aList, label); newPeer { |
451 | // we added a previously unknown peer: send a HELLO | 464 | // we added a previously unknown peer: send a HELLO |
452 | var msgOut *message.DHTP2PHelloMsg | 465 | var msgOut *message.DHTP2PHelloMsg |
453 | if msgOut, err = m.getHello(); err != nil { | 466 | if msgOut, err = m.getHello(label); err != nil { |
454 | return false | 467 | return false |
455 | } | 468 | } |
456 | logger.Printf(logger.INFO, "[%s] Sending HELLO to %s: %s", label, sender, msgOut) | 469 | logger.Printf(logger.INFO, "[%s] Sending own HELLO to %s", label, sender.Short()) |
457 | err = m.core.Send(ctx, sender, msgOut) | 470 | err = m.core.Send(ctx, sender, msgOut) |
458 | // no error if the message might have been sent | 471 | // no error if the message might have been sent |
459 | if err != nil && err != transport.ErrEndpMaybeSent { | 472 | if err != nil && err != transport.ErrEndpMaybeSent { |
460 | logger.Printf(logger.ERROR, "[%s] Failed to send HELLO message: %s", label, err.Error()) | 473 | logger.Printf(logger.ERROR, "[%s] -> failed to send HELLO message: %s", label, err.Error()) |
461 | } | 474 | } |
462 | } | 475 | } |
463 | 476 | ||
@@ -466,14 +479,14 @@ func (m *Module) HandleMessage(ctx context.Context, sender *util.PeerID, msgIn m | |||
466 | isNew := true | 479 | isNew := true |
467 | if hb, ok := m.rtable.GetHello(k); ok { | 480 | if hb, ok := m.rtable.GetHello(k); ok { |
468 | // cache entry exists: is the HELLO message more recent? | 481 | // cache entry exists: is the HELLO message more recent? |
469 | _, isNew = hb.Expires.Diff(msg.Expires) | 482 | _, isNew = hb.Expire_.Diff(msg.Expire) |
470 | } | 483 | } |
471 | // we need to cache a new(er) HELLO | 484 | // we need to cache a new(er) HELLO |
472 | if isNew { | 485 | if isNew { |
473 | m.rtable.CacheHello(&blocks.HelloBlock{ | 486 | m.rtable.CacheHello(&blocks.HelloBlock{ |
474 | PeerID: sender, | 487 | PeerID: sender, |
475 | Signature: msg.Signature, | 488 | Signature: msg.Signature, |
476 | Expires: msg.Expires, | 489 | Expire_: msg.Expire, |
477 | AddrBin: util.Clone(msg.AddrList), | 490 | AddrBin: util.Clone(msg.AddrList), |
478 | }) | 491 | }) |
479 | } | 492 | } |
@@ -486,51 +499,68 @@ func (m *Module) HandleMessage(ctx context.Context, sender *util.PeerID, msgIn m | |||
486 | //---------------------------------------------------------- | 499 | //---------------------------------------------------------- |
487 | // DHT PUT | 500 | // DHT PUT |
488 | //---------------------------------------------------------- | 501 | //---------------------------------------------------------- |
489 | logger.Printf(logger.INFO, "[%s] Handling DHTClientPut message", label) | 502 | logger.Printf(logger.INFO, "[%s] Ignoring DHTClientPut message", label) |
490 | 503 | ||
491 | case *message.DHTClientGetMsg: | 504 | case *message.DHTClientGetMsg: |
492 | //---------------------------------------------------------- | 505 | //---------------------------------------------------------- |
493 | // DHT GET | 506 | // DHT GET |
494 | //---------------------------------------------------------- | 507 | //---------------------------------------------------------- |
495 | logger.Printf(logger.INFO, "[%s] Handling DHTClientGet message", label) | 508 | logger.Printf(logger.INFO, "[%s] Ignoring DHTClientGet message", label) |
496 | 509 | ||
497 | case *message.DHTClientGetResultsKnownMsg: | 510 | case *message.DHTClientGetResultsKnownMsg: |
498 | //---------------------------------------------------------- | 511 | //---------------------------------------------------------- |
499 | // DHT GET-RESULTS-KNOWN | 512 | // DHT GET-RESULTS-KNOWN |
500 | //---------------------------------------------------------- | 513 | //---------------------------------------------------------- |
501 | logger.Printf(logger.INFO, "[%s] Handling DHTClientGetResultsKnown message", label) | 514 | logger.Printf(logger.INFO, "[%s] Ignoring DHTClientGetResultsKnown message", label) |
502 | 515 | ||
503 | case *message.DHTClientGetStopMsg: | 516 | case *message.DHTClientGetStopMsg: |
504 | //---------------------------------------------------------- | 517 | //---------------------------------------------------------- |
505 | // DHT GET-STOP | 518 | // DHT GET-STOP |
506 | //---------------------------------------------------------- | 519 | //---------------------------------------------------------- |
507 | logger.Printf(logger.INFO, "[%s] Handling DHTClientGetStop message", label) | 520 | logger.Printf(logger.INFO, "[%s] Ignoring DHTClientGetStop message", label) |
508 | 521 | ||
509 | case *message.DHTClientResultMsg: | 522 | case *message.DHTClientResultMsg: |
510 | //---------------------------------------------------------- | 523 | //---------------------------------------------------------- |
511 | // DHT RESULT | 524 | // DHT RESULT |
512 | //---------------------------------------------------------- | 525 | //---------------------------------------------------------- |
513 | logger.Printf(logger.INFO, "[%s] Handling DHTClientResult message", label) | 526 | logger.Printf(logger.INFO, "[%s] Ignoring DHTClientResult message", label) |
514 | 527 | ||
515 | default: | 528 | default: |
516 | //---------------------------------------------------------- | 529 | //---------------------------------------------------------- |
517 | // UNKNOWN message type received | 530 | // UNKNOWN message type received |
518 | //---------------------------------------------------------- | 531 | //---------------------------------------------------------- |
519 | logger.Printf(logger.ERROR, "[%s] Unhandled message of type (%d)\n", label, msgIn.Header().MsgType) | 532 | logger.Printf(logger.ERROR, "[%s] Unhandled message of type (%s)\n", label, msgIn.Type()) |
520 | return false | 533 | return false |
521 | } | 534 | } |
522 | return true | 535 | return true |
523 | } | 536 | } |
524 | 537 | ||
538 | //---------------------------------------------------------------------- | ||
539 | // Helpers | ||
540 | //---------------------------------------------------------------------- | ||
541 | |||
525 | // send a result back to caller | 542 | // send a result back to caller |
526 | func (m *Module) sendResult(ctx context.Context, query blocks.Query, blk blocks.Block, pth *path.Path, back transport.Responder) error { | 543 | func (m *Module) sendResult(ctx context.Context, query blocks.Query, blk blocks.Block, pth *path.Path, back transport.Responder) error { |
527 | // assemble result message | 544 | // assemble result message |
528 | out := message.NewDHTP2PResultMsg() | 545 | out := message.NewDHTP2PResultMsg() |
529 | out.BType = uint32(query.Type()) | 546 | out.BType = query.Type() |
530 | out.Expires = blk.Expire() | 547 | out.Flags = query.Flags() |
548 | out.Expire = blk.Expire() | ||
531 | out.Query = query.Key() | 549 | out.Query = query.Key() |
532 | out.Block = blk.Bytes() | 550 | out.Block = blk.Bytes() |
533 | out.MsgSize += uint16(len(out.Block)) | 551 | out.MsgSize += uint16(len(out.Block)) |
552 | out.SetPath(pth) | ||
553 | |||
534 | // send message | 554 | // send message |
535 | return back.Send(ctx, out) | 555 | return back.Send(ctx, out) |
536 | } | 556 | } |
557 | |||
558 | // get enforced action for GET message | ||
559 | func getActions(closest, demux, approx bool) (doResult, doForward bool) { | ||
560 | return closest || (demux && approx), !closest || (demux && !approx) | ||
561 | } | ||
562 | |||
563 | // get enforced action for PUT message | ||
564 | func putActions(closest, demux bool) (doStore, doForward bool) { | ||
565 | return closest || demux, !closest || demux | ||
566 | } | ||
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 @@ | |||
1 | // This file is part of gnunet-go, a GNUnet-implementation in Golang. | ||
2 | // Copyright (C) 2019-2022 Bernd Fix >Y< | ||
3 | // | ||
4 | // gnunet-go is free software: you can redistribute it and/or modify it | ||
5 | // under the terms of the GNU Affero General Public License as published | ||
6 | // by the Free Software Foundation, either version 3 of the License, | ||
7 | // or (at your option) any later version. | ||
8 | // | ||
9 | // gnunet-go is distributed in the hope that it will be useful, but | ||
10 | // WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | // Affero General Public License for more details. | ||
13 | // | ||
14 | // You should have received a copy of the GNU Affero General Public License | ||
15 | // along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | // | ||
17 | // SPDX-License-Identifier: AGPL3.0-or-later | ||
18 | |||
19 | package dht | ||
20 | |||
21 | import "testing" | ||
22 | |||
23 | func TestGetActions(t *testing.T) { | ||
24 | var data = [][]bool{ | ||
25 | // closest, demux, approx => doResult, doForward | ||
26 | // | ||
27 | // | N | N | N | => | N | Y | Forward GET msg to neighbors | ||
28 | // | Y | N | N | => | Y | N | Return block if in DHT | ||
29 | // | N | N | Y | => | N | Y | Forward GET msg to neighbors | ||
30 | // | Y | N | Y | => | Y | N | Return best-match block from DHT | ||
31 | // | N | Y | N | => | N | Y | Forward GET msg to neighbors | ||
32 | // | Y | Y | N | => | Y | Y | Return block if in DHT and forward GET | ||
33 | // | N | Y | Y | => | Y | Y | Return best-match block from DHT than forward GET | ||
34 | // | Y | Y | Y | => | Y | N | Return best-match block from DHT | ||
35 | // | ||
36 | {false, false, false, false, true}, | ||
37 | {true, false, false, true, false}, | ||
38 | {false, false, true, false, true}, | ||
39 | {true, false, true, true, false}, | ||
40 | {false, true, false, false, true}, | ||
41 | {true, true, false, true, true}, | ||
42 | {false, true, true, true, true}, | ||
43 | {true, true, true, true, false}, | ||
44 | } | ||
45 | for i, d := range data { | ||
46 | r1, r2 := getActions(d[0], d[1], d[2]) | ||
47 | if r1 != d[3] || r2 != d[4] { | ||
48 | t.Errorf("Failed entry #%d: %v -- got: %v,%v", i, d, r1, r2) | ||
49 | } | ||
50 | } | ||
51 | } | ||
52 | |||
53 | func TestPutActions(t *testing.T) { | ||
54 | var data = [][]bool{ | ||
55 | // closest, demux => doStore, doForward | ||
56 | // | ||
57 | // | N | N | => | N | Y | Forward PUT msg | ||
58 | // | Y | N | => | Y | N | store block in DHT | ||
59 | // | N | Y | => | Y | Y | Store block in DHT and forward PUT msg | ||
60 | // | Y | Y | => | Y | Y | Store block in DHT and forward PUT msg | ||
61 | // | ||
62 | {false, false, false, true}, | ||
63 | {true, false, true, false}, | ||
64 | {false, true, true, true}, | ||
65 | {true, true, true, true}, | ||
66 | } | ||
67 | for i, d := range data { | ||
68 | r1, r2 := putActions(d[0], d[1]) | ||
69 | if r1 != d[2] || r2 != d[3] { | ||
70 | t.Errorf("Failed entry #%d: %v -- got: %v,%v", i, d, r1, r2) | ||
71 | } | ||
72 | } | ||
73 | } | ||
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 | |||
20 | 20 | ||
21 | import ( | 21 | import ( |
22 | "context" | 22 | "context" |
23 | "errors" | 23 | "encoding/hex" |
24 | "fmt" | ||
24 | "gnunet/config" | 25 | "gnunet/config" |
25 | "gnunet/core" | 26 | "gnunet/core" |
26 | "gnunet/crypto" | 27 | "gnunet/crypto" |
@@ -71,10 +72,15 @@ func (lr *LocalBlockResponder) Send(ctx context.Context, msg message.Message) er | |||
71 | case *message.DHTP2PResultMsg: | 72 | case *message.DHTP2PResultMsg: |
72 | // deliver incoming blocks | 73 | // deliver incoming blocks |
73 | go func() { | 74 | go func() { |
74 | lr.ch <- blocks.NewGenericBlock(res.Block) | 75 | blk, err := blocks.NewBlock(enums.BlockType(res.BType), res.Expire, res.Block) |
76 | if err == nil { | ||
77 | lr.ch <- blk | ||
78 | } else { | ||
79 | logger.Println(logger.WARN, "[local] DHT-RESULT block problem: "+err.Error()) | ||
80 | } | ||
75 | }() | 81 | }() |
76 | default: | 82 | default: |
77 | logger.Println(logger.WARN, "[local] not a DHT-RESULT -- skipped") | 83 | logger.Printf(logger.WARN, "[local] %d not a DHT-RESULT -- skipped", "") |
78 | } | 84 | } |
79 | return nil | 85 | return nil |
80 | } | 86 | } |
@@ -133,8 +139,8 @@ func NewModule(ctx context.Context, c *core.Core, cfg *config.DHTConfig) (m *Mod | |||
133 | 139 | ||
134 | // run periodic tasks (8.2. peer discovery) | 140 | // run periodic tasks (8.2. peer discovery) |
135 | ticker := time.NewTicker(5 * time.Minute) | 141 | ticker := time.NewTicker(5 * time.Minute) |
136 | key := crypto.Hash(m.core.PeerID().Data) | 142 | key := crypto.Hash(m.core.PeerID().Bytes()) |
137 | flags := uint16(enums.DHT_RO_FIND_APPROXIMATE | enums.DHT_RO_DEMULTIPLEX_EVERYWHERE) | 143 | flags := uint16(enums.DHT_RO_FIND_APPROXIMATE | enums.DHT_RO_DEMULTIPLEX_EVERYWHERE | enums.DHT_RO_DISCOVERY) |
138 | var resCh <-chan blocks.Block | 144 | var resCh <-chan blocks.Block |
139 | go func() { | 145 | go func() { |
140 | for { | 146 | for { |
@@ -142,25 +148,29 @@ func NewModule(ctx context.Context, c *core.Core, cfg *config.DHTConfig) (m *Mod | |||
142 | // initiate peer discovery | 148 | // initiate peer discovery |
143 | case <-ticker.C: | 149 | case <-ticker.C: |
144 | // query DHT for our own HELLO block | 150 | // query DHT for our own HELLO block |
145 | query := blocks.NewGenericQuery(key, enums.BLOCK_TYPE_DHT_HELLO, flags) | 151 | query := blocks.NewGenericQuery(key, enums.BLOCK_TYPE_DHT_URL_HELLO, flags) |
152 | logger.Printf(logger.DBG, "[dht-discovery] own HELLO key %s", query.Key().Short()) | ||
146 | resCh = m.Get(ctx, query) | 153 | resCh = m.Get(ctx, query) |
147 | 154 | ||
148 | // handle peer discover results | 155 | // handle peer discover results |
149 | case res := <-resCh: | 156 | case res := <-resCh: |
150 | // check for correct type | 157 | // check for correct type |
151 | btype := res.Type() | 158 | btype := res.Type() |
152 | if btype == enums.BLOCK_TYPE_DHT_HELLO { | 159 | if btype == enums.BLOCK_TYPE_DHT_URL_HELLO { |
153 | hb, ok := res.(*blocks.HelloBlock) | 160 | hb, ok := res.(*blocks.HelloBlock) |
154 | if !ok { | 161 | if !ok { |
155 | logger.Printf(logger.WARN, "[dht] peer discovery received invalid block data") | 162 | logger.Println(logger.WARN, "[dht-discovery] received invalid block data") |
163 | logger.Printf(logger.DBG, "[dht-discovery] -> %s", hex.EncodeToString(res.Bytes())) | ||
156 | } else { | 164 | } else { |
157 | // cache HELLO block | 165 | // cache HELLO block |
158 | m.rtable.CacheHello(hb) | 166 | m.rtable.CacheHello(hb) |
159 | // add sender to routing table | 167 | // add sender to routing table |
160 | m.rtable.Add(NewPeerAddress(hb.PeerID), "dht") | 168 | m.rtable.Add(NewPeerAddress(hb.PeerID), "dht-discovery") |
169 | // learn addresses | ||
170 | m.core.Learn(ctx, hb.PeerID, hb.Addresses(), "dht-discovery") | ||
161 | } | 171 | } |
162 | } else { | 172 | } else { |
163 | logger.Printf(logger.WARN, "[dht] peer discovery received invalid block type %s", btype.String()) | 173 | logger.Printf(logger.WARN, "[dht-discovery] received invalid block type %s", btype) |
164 | } | 174 | } |
165 | 175 | ||
166 | // termination | 176 | // termination |
@@ -198,9 +208,10 @@ func (m *Module) Get(ctx context.Context, query blocks.Query) <-chan blocks.Bloc | |||
198 | 208 | ||
199 | // assemble a new GET message | 209 | // assemble a new GET message |
200 | msg := message.NewDHTP2PGetMsg() | 210 | msg := message.NewDHTP2PGetMsg() |
201 | msg.BType = uint32(query.Type()) | 211 | msg.BType = query.Type() |
202 | msg.Flags = query.Flags() | 212 | msg.Flags = query.Flags() |
203 | msg.HopCount = 0 | 213 | msg.HopCount = 0 |
214 | msg.Query = query.Key() | ||
204 | msg.ReplLevel = uint16(m.cfg.Routing.ReplLevel) | 215 | msg.ReplLevel = uint16(m.cfg.Routing.ReplLevel) |
205 | msg.PeerFilter = blocks.NewPeerFilter() | 216 | msg.PeerFilter = blocks.NewPeerFilter() |
206 | msg.ResFilter = rf.Bytes() | 217 | msg.ResFilter = rf.Bytes() |
@@ -231,11 +242,6 @@ func (m *Module) Get(ctx context.Context, query blocks.Query) <-chan blocks.Bloc | |||
231 | return hdlr.C() | 242 | return hdlr.C() |
232 | } | 243 | } |
233 | 244 | ||
234 | // GetApprox returns the first block not excluded ["dht:getapprox"] | ||
235 | func (m *Module) GetApprox(ctx context.Context, query blocks.Query, rf blocks.ResultFilter) (results []*store.DHTResult, err error) { | ||
236 | return m.store.GetApprox("dht", query, rf) | ||
237 | } | ||
238 | |||
239 | // Put a block into the DHT ["dht:put"] | 245 | // Put a block into the DHT ["dht:put"] |
240 | func (m *Module) Put(ctx context.Context, query blocks.Query, block blocks.Block) error { | 246 | func (m *Module) Put(ctx context.Context, query blocks.Query, block blocks.Block) error { |
241 | // get additional query parameters | 247 | // get additional query parameters |
@@ -245,12 +251,12 @@ func (m *Module) Put(ctx context.Context, query blocks.Query, block blocks.Block | |||
245 | } | 251 | } |
246 | // assemble a new PUT message | 252 | // assemble a new PUT message |
247 | msg := message.NewDHTP2PPutMsg() | 253 | msg := message.NewDHTP2PPutMsg() |
248 | msg.BType = uint32(query.Type()) | 254 | msg.BType = query.Type() |
249 | msg.Flags = query.Flags() | 255 | msg.Flags = query.Flags() |
250 | msg.HopCount = 0 | 256 | msg.HopCount = 0 |
251 | msg.PeerFilter = blocks.NewPeerFilter() | 257 | msg.PeerFilter = blocks.NewPeerFilter() |
252 | msg.ReplLvl = uint16(m.cfg.Routing.ReplLevel) | 258 | msg.ReplLvl = uint16(m.cfg.Routing.ReplLevel) |
253 | msg.Expiration = expire | 259 | msg.Expire = expire |
254 | msg.Block = block.Bytes() | 260 | msg.Block = block.Bytes() |
255 | msg.Key = query.Key().Clone() | 261 | msg.Key = query.Key().Clone() |
256 | msg.TruncOrigin = nil | 262 | msg.TruncOrigin = nil |
@@ -259,7 +265,9 @@ func (m *Module) Put(ctx context.Context, query blocks.Query, block blocks.Block | |||
259 | msg.MsgSize += uint16(len(msg.Block)) | 265 | msg.MsgSize += uint16(len(msg.Block)) |
260 | 266 | ||
261 | // send message | 267 | // send message |
262 | go m.HandleMessage(ctx, nil, msg, nil) | 268 | self := m.core.PeerID() |
269 | msg.PeerFilter.Add(self) | ||
270 | go m.HandleMessage(ctx, self, msg, nil) | ||
263 | 271 | ||
264 | return nil | 272 | return nil |
265 | } | 273 | } |
@@ -277,16 +285,16 @@ func (m *Module) Filter() *core.EventFilter { | |||
277 | 285 | ||
278 | // messages we are interested in: | 286 | // messages we are interested in: |
279 | // (1) DHT_P2P messages | 287 | // (1) DHT_P2P messages |
280 | f.AddMsgType(message.DHT_P2P_PUT) | 288 | f.AddMsgType(enums.MSG_DHT_P2P_PUT) |
281 | f.AddMsgType(message.DHT_P2P_GET) | 289 | f.AddMsgType(enums.MSG_DHT_P2P_GET) |
282 | f.AddMsgType(message.DHT_P2P_RESULT) | 290 | f.AddMsgType(enums.MSG_DHT_P2P_RESULT) |
283 | f.AddMsgType(message.DHT_P2P_HELLO) | 291 | f.AddMsgType(enums.MSG_DHT_P2P_HELLO) |
284 | // (2) DHT messages (legacy, not implemented) | 292 | // (2) DHT messages (legacy, not implemented) |
285 | f.AddMsgType(message.DHT_CLIENT_GET) | 293 | f.AddMsgType(enums.MSG_DHT_CLIENT_GET) |
286 | f.AddMsgType(message.DHT_CLIENT_GET_RESULTS_KNOWN) | 294 | f.AddMsgType(enums.MSG_DHT_CLIENT_GET_RESULTS_KNOWN) |
287 | f.AddMsgType(message.DHT_CLIENT_GET_STOP) | 295 | f.AddMsgType(enums.MSG_DHT_CLIENT_GET_STOP) |
288 | f.AddMsgType(message.DHT_CLIENT_PUT) | 296 | f.AddMsgType(enums.MSG_DHT_CLIENT_PUT) |
289 | f.AddMsgType(message.DHT_CLIENT_RESULT) | 297 | f.AddMsgType(enums.MSG_DHT_CLIENT_RESULT) |
290 | 298 | ||
291 | return f | 299 | return f |
292 | } | 300 | } |
@@ -297,27 +305,28 @@ func (m *Module) event(ctx context.Context, ev *core.Event) { | |||
297 | // New peer connected: | 305 | // New peer connected: |
298 | case core.EV_CONNECT: | 306 | case core.EV_CONNECT: |
299 | // Add peer to routing table | 307 | // Add peer to routing table |
300 | logger.Printf(logger.INFO, "[dht-event] Peer %s connected", ev.Peer) | 308 | logger.Printf(logger.INFO, "[dht-event] Peer %s connected", ev.Peer.Short()) |
301 | m.rtable.Add(NewPeerAddress(ev.Peer), "dht-event") | 309 | m.rtable.Add(NewPeerAddress(ev.Peer), "dht-event") |
302 | 310 | ||
303 | // Peer disconnected: | 311 | // Peer disconnected: |
304 | case core.EV_DISCONNECT: | 312 | case core.EV_DISCONNECT: |
305 | // Remove peer from routing table | 313 | // Remove peer from routing table |
306 | logger.Printf(logger.INFO, "[dht-event] Peer %s disconnected", ev.Peer) | 314 | logger.Printf(logger.INFO, "[dht-event] Peer %s disconnected", ev.Peer.Short()) |
307 | m.rtable.Remove(NewPeerAddress(ev.Peer), 0) | 315 | m.rtable.Remove(NewPeerAddress(ev.Peer), "dht-event", 0) |
308 | 316 | ||
309 | // Message received. | 317 | // Message received. |
310 | case core.EV_MESSAGE: | 318 | case core.EV_MESSAGE: |
311 | logger.Printf(logger.INFO, "[dht-event] Message received: %s", ev.Msg.String()) | 319 | // generate tracking label |
312 | 320 | label := fmt.Sprintf("dht-msg-%d", util.NextID()) | |
321 | tctx := context.WithValue(ctx, core.CtxKey("label"), label) | ||
313 | // check if peer is in routing table (connected peer) | 322 | // check if peer is in routing table (connected peer) |
314 | if !m.rtable.Contains(NewPeerAddress(ev.Peer)) { | 323 | if !m.rtable.Contains(NewPeerAddress(ev.Peer), label) { |
315 | logger.Printf(logger.WARN, "[dht-event] message %d from unregistered peer -- discarded", ev.Msg.Header().MsgType) | 324 | logger.Printf(logger.WARN, "[%s] message %d from unregistered peer -- discarded", label, ev.Msg.Type()) |
316 | return | 325 | return |
317 | } | 326 | } |
318 | // process message | 327 | // process message |
319 | if !m.HandleMessage(ctx, ev.Peer, ev.Msg, ev.Resp) { | 328 | if !m.HandleMessage(tctx, ev.Peer, ev.Msg, ev.Resp) { |
320 | logger.Println(logger.WARN, "[dht-event] Message NOT handled!") | 329 | logger.Printf(logger.WARN, "[%s] %s message NOT handled", label, ev.Msg.Type()) |
321 | } | 330 | } |
322 | } | 331 | } |
323 | } | 332 | } |
@@ -337,20 +346,20 @@ func (m *Module) heartbeat(ctx context.Context) { | |||
337 | //---------------------------------------------------------------------- | 346 | //---------------------------------------------------------------------- |
338 | 347 | ||
339 | // Send the currently active HELLO to given network address | 348 | // Send the currently active HELLO to given network address |
340 | func (m *Module) SendHello(ctx context.Context, addr *util.Address) (err error) { | 349 | func (m *Module) SendHello(ctx context.Context, addr *util.Address, label string) (err error) { |
341 | // get (buffered) HELLO | 350 | // get (buffered) HELLO |
342 | var msg *message.DHTP2PHelloMsg | 351 | var msg *message.DHTP2PHelloMsg |
343 | if msg, err = m.getHello(); err != nil { | 352 | if msg, err = m.getHello(label); err != nil { |
344 | return | 353 | return |
345 | } | 354 | } |
346 | logger.Printf(logger.INFO, "[core] Sending HELLO to %s: %s", addr.URI(), msg) | 355 | logger.Printf(logger.INFO, "[%s] Sending own HELLO to %s", label, addr.URI()) |
347 | return m.core.SendToAddr(ctx, addr, msg) | 356 | return m.core.SendToAddr(ctx, addr, msg) |
348 | } | 357 | } |
349 | 358 | ||
350 | // get the recent HELLO if it is defined and not expired; | 359 | // get the recent HELLO if it is defined and not expired; |
351 | // create a new HELLO otherwise. | 360 | // create a new HELLO otherwise. |
352 | func (m *Module) getHello() (msg *message.DHTP2PHelloMsg, err error) { | 361 | func (m *Module) getHello(label string) (msg *message.DHTP2PHelloMsg, err error) { |
353 | if m.lastHello == nil || m.lastHello.Expires.Expired() { | 362 | if m.lastHello == nil || m.lastHello.Expire.Expired() { |
354 | // assemble new (signed) HELLO block | 363 | // assemble new (signed) HELLO block |
355 | var addrList []*util.Address | 364 | var addrList []*util.Address |
356 | if addrList, err = m.core.Addresses(); err != nil { | 365 | if addrList, err = m.core.Addresses(); err != nil { |
@@ -359,7 +368,7 @@ func (m *Module) getHello() (msg *message.DHTP2PHelloMsg, err error) { | |||
359 | // assemble HELLO data | 368 | // assemble HELLO data |
360 | hb := new(blocks.HelloBlock) | 369 | hb := new(blocks.HelloBlock) |
361 | hb.PeerID = m.core.PeerID() | 370 | hb.PeerID = m.core.PeerID() |
362 | hb.Expires = util.NewAbsoluteTime(time.Now().Add(message.HelloAddressExpiration)) | 371 | hb.Expire_ = util.NewAbsoluteTime(time.Now().Add(message.HelloAddressExpiration)) |
363 | hb.SetAddresses(addrList) | 372 | hb.SetAddresses(addrList) |
364 | 373 | ||
365 | // sign HELLO block | 374 | // sign HELLO block |
@@ -368,12 +377,11 @@ func (m *Module) getHello() (msg *message.DHTP2PHelloMsg, err error) { | |||
368 | } | 377 | } |
369 | // assemble HELLO message | 378 | // assemble HELLO message |
370 | msg = message.NewDHTP2PHelloMsg() | 379 | msg = message.NewDHTP2PHelloMsg() |
371 | msg.Expires = hb.Expires | 380 | msg.Expire = hb.Expire_ |
372 | msg.SetAddresses(hb.Addresses()) | 381 | msg.SetAddresses(hb.Addresses()) |
373 | if err = m.core.Sign(msg); err != nil { | 382 | if err = m.core.Sign(msg); err != nil { |
374 | return | 383 | return |
375 | } | 384 | } |
376 | |||
377 | // save for later use | 385 | // save for later use |
378 | m.lastHello = msg | 386 | m.lastHello = msg |
379 | 387 | ||
@@ -381,12 +389,12 @@ func (m *Module) getHello() (msg *message.DHTP2PHelloMsg, err error) { | |||
381 | var ok bool | 389 | var ok bool |
382 | if ok, err = msg.Verify(m.core.PeerID()); !ok || err != nil { | 390 | if ok, err = msg.Verify(m.core.PeerID()); !ok || err != nil { |
383 | if !ok { | 391 | if !ok { |
384 | err = errors.New("failed to verify own HELLO") | 392 | err = fmt.Errorf("[%s] failed to verify own HELLO", label) |
385 | } | 393 | } |
386 | logger.Println(logger.ERROR, err.Error()) | 394 | logger.Println(logger.ERROR, err.Error()) |
387 | return | 395 | return |
388 | } | 396 | } |
389 | logger.Println(logger.DBG, "[dht] New HELLO: "+util.Dump(msg, "hex")) | 397 | logger.Printf(logger.INFO, "[%s] new own HELLO created (expires %s)", label, msg.Expire) |
390 | return | 398 | return |
391 | } | 399 | } |
392 | // we have a valid HELLO for re-use. | 400 | // we have a valid HELLO for re-use. |
@@ -401,7 +409,6 @@ func (m *Module) getHello() (msg *message.DHTP2PHelloMsg, err error) { | |||
401 | func (m *Module) Export(fcn map[string]any) { | 409 | func (m *Module) Export(fcn map[string]any) { |
402 | // add exported functions from module | 410 | // add exported functions from module |
403 | fcn["dht:get"] = m.Get | 411 | fcn["dht:get"] = m.Get |
404 | fcn["dht:getapprox"] = m.GetApprox | ||
405 | fcn["dht:put"] = m.Put | 412 | fcn["dht:put"] = m.Put |
406 | } | 413 | } |
407 | 414 | ||
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 { | |||
60 | //---------------------------------------------------------------------- | 60 | //---------------------------------------------------------------------- |
61 | // shared path element data across types | 61 | // shared path element data across types |
62 | type elementData struct { | 62 | type elementData struct { |
63 | Expiration util.AbsoluteTime // expiration date | 63 | Expire util.AbsoluteTime // expiration date |
64 | BlockHash *crypto.HashCode // block hash | 64 | BlockHash *crypto.HashCode // block hash |
65 | PeerPredecessor *util.PeerID // predecessor peer | 65 | PeerPredecessor *util.PeerID // predecessor peer |
66 | PeerSuccessor *util.PeerID // successor peer | 66 | 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 { | |||
129 | func (p *Path) NewElement(pred, signer, succ *util.PeerID) *Element { | 129 | func (p *Path) NewElement(pred, signer, succ *util.PeerID) *Element { |
130 | return &Element{ | 130 | return &Element{ |
131 | elementData: elementData{ | 131 | elementData: elementData{ |
132 | Expiration: p.Expire, | 132 | Expire: p.Expire, |
133 | BlockHash: p.BlkHash, | 133 | BlockHash: p.BlkHash, |
134 | PeerPredecessor: pred, | 134 | PeerPredecessor: pred, |
135 | PeerSuccessor: succ, | 135 | 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 ( | |||
44 | // different GET requests and/or differnent originators). | 44 | // different GET requests and/or differnent originators). |
45 | //====================================================================== | 45 | //====================================================================== |
46 | 46 | ||
47 | // ResultHandler interface | ||
48 | type ResultHandler interface { | ||
49 | |||
50 | // ID returna the handler id | ||
51 | ID() int | ||
52 | |||
53 | // Done returns true if handler can be removed | ||
54 | Done() bool | ||
55 | |||
56 | // Key returns the query/store key as string | ||
57 | Key() *crypto.HashCode | ||
58 | |||
59 | // Flags returns the query flags | ||
60 | Flags() uint16 | ||
61 | |||
62 | // Compare two result handlers | ||
63 | Compare(ResultHandler) int | ||
64 | |||
65 | // Merge two result handlers that are the same except for result filter | ||
66 | Merge(ResultHandler) bool | ||
67 | |||
68 | // Handle result message | ||
69 | Handle(ctx context.Context, msg *message.DHTP2PResultMsg, pth *path.Path, sender, local *util.PeerID) bool | ||
70 | } | ||
71 | |||
72 | // Compare return values | 47 | // Compare return values |
73 | //nolint:stylecheck // allow non-camel-case in constants | 48 | //nolint:stylecheck // allow non-camel-case in constants |
74 | const ( | 49 | const ( |
@@ -78,24 +53,23 @@ const ( | |||
78 | RHC_REPLACE = blocks.CMP_1 // the two result handlers are siblings | 53 | RHC_REPLACE = blocks.CMP_1 // the two result handlers are siblings |
79 | ) | 54 | ) |
80 | 55 | ||
81 | //---------------------------------------------------------------------- | 56 | // ResultHandler for handling DHT-RESULT messages |
82 | 57 | type ResultHandler struct { | |
83 | // Generic (shared) result handler data structure | ||
84 | type GenericResultHandler struct { | ||
85 | id int // task identifier | 58 | id int // task identifier |
86 | key *crypto.HashCode // GET query key | 59 | key *crypto.HashCode // GET query key |
87 | btype uint32 // content type of the payload | 60 | btype enums.BlockType // content type of the payload |
88 | flags uint16 // processing flags | 61 | flags uint16 // processing flags |
89 | resFilter blocks.ResultFilter // result filter | 62 | resFilter blocks.ResultFilter // result filter |
90 | xQuery []byte // extended query | 63 | xQuery []byte // extended query |
91 | started util.AbsoluteTime // Timestamp of session start | 64 | started util.AbsoluteTime // Timestamp of session start |
92 | active bool // is the task active? | 65 | active bool // is the task active? |
66 | resp transport.Responder // back-channel to deliver result | ||
93 | } | 67 | } |
94 | 68 | ||
95 | // NewGenericResultHandler creates an instance from a DHT-GET message and a | 69 | // NewResultHandler creates an instance from a DHT-GET message and a |
96 | // result filter instance. | 70 | // result filter instance. |
97 | func NewGenericResultHandler(msg *message.DHTP2PGetMsg, rf blocks.ResultFilter) *GenericResultHandler { | 71 | func NewResultHandler(msg *message.DHTP2PGetMsg, rf blocks.ResultFilter, back transport.Responder) *ResultHandler { |
98 | return &GenericResultHandler{ | 72 | return &ResultHandler{ |
99 | id: util.NextID(), | 73 | id: util.NextID(), |
100 | key: msg.Query.Clone(), | 74 | key: msg.Query.Clone(), |
101 | btype: msg.BType, | 75 | btype: msg.BType, |
@@ -104,37 +78,45 @@ func NewGenericResultHandler(msg *message.DHTP2PGetMsg, rf blocks.ResultFilter) | |||
104 | xQuery: util.Clone(msg.XQuery), | 78 | xQuery: util.Clone(msg.XQuery), |
105 | started: util.AbsoluteTimeNow(), | 79 | started: util.AbsoluteTimeNow(), |
106 | active: true, | 80 | active: true, |
81 | resp: back, | ||
107 | } | 82 | } |
108 | } | 83 | } |
109 | 84 | ||
110 | // ID returns the result handler identifier | 85 | // ID returns the result handler identifier |
111 | func (t *GenericResultHandler) ID() int { | 86 | func (t *ResultHandler) ID() int { |
112 | return t.id | 87 | return t.id |
113 | } | 88 | } |
114 | 89 | ||
115 | // Key returns the key string | 90 | // Key returns the key string |
116 | func (t *GenericResultHandler) Key() *crypto.HashCode { | 91 | func (t *ResultHandler) Key() *crypto.HashCode { |
117 | return t.key | 92 | return t.key |
118 | } | 93 | } |
119 | 94 | ||
120 | // Flags returns the query flags | 95 | // Flags returns the query flags |
121 | func (t *GenericResultHandler) Flags() uint16 { | 96 | func (t *ResultHandler) Flags() uint16 { |
122 | return t.flags | 97 | return t.flags |
123 | } | 98 | } |
124 | 99 | ||
125 | // Done returns true if the result handler is no longer active. | 100 | // Done returns true if the result handler is no longer active. |
126 | func (t *GenericResultHandler) Done() bool { | 101 | func (t *ResultHandler) Done() bool { |
127 | return !t.active || t.started.Add(time.Hour).Expired() | 102 | return !t.active || t.started.Add(time.Hour).Expired() |
128 | } | 103 | } |
129 | 104 | ||
130 | // Compare two handlers | 105 | // Compare two handlers |
131 | func (t *GenericResultHandler) Compare(h *GenericResultHandler) int { | 106 | func (t *ResultHandler) Compare(h *ResultHandler) int { |
107 | // check for same recipient | ||
108 | tRcv := t.resp.Receiver() | ||
109 | hRcv := h.resp.Receiver() | ||
110 | if !hRcv.Equal(tRcv) { | ||
111 | logger.Printf(logger.DBG, "[rh] recipients differ: %v -- %v", hRcv, tRcv) | ||
112 | return RHC_DIFFER | ||
113 | } | ||
132 | // check if base attributes differ | 114 | // check if base attributes differ |
133 | if !t.key.Equals(h.key) || | 115 | if !t.key.Equal(h.key) || |
134 | t.btype != h.btype || | 116 | t.btype != h.btype || |
135 | t.flags != h.flags || | 117 | t.flags != h.flags || |
136 | !bytes.Equal(t.xQuery, h.xQuery) { | 118 | !bytes.Equal(t.xQuery, h.xQuery) { |
137 | logger.Printf(logger.DBG, "[grh] base fields differ") | 119 | logger.Printf(logger.DBG, "[rh] base fields differ") |
138 | return RHC_DIFFER | 120 | return RHC_DIFFER |
139 | } | 121 | } |
140 | // compare result filters; if they are different, replace | 122 | // compare result filters; if they are different, replace |
@@ -147,180 +129,52 @@ func (t *GenericResultHandler) Compare(h *GenericResultHandler) int { | |||
147 | } | 129 | } |
148 | 130 | ||
149 | // Merge two result handlers that are the same except for result filter | 131 | // Merge two result handlers that are the same except for result filter |
150 | func (t *GenericResultHandler) Merge(a *GenericResultHandler) bool { | 132 | func (t *ResultHandler) Merge(a *ResultHandler) bool { |
151 | return t.resFilter.Merge(a.resFilter) | 133 | return t.resFilter.Merge(a.resFilter) |
152 | } | 134 | } |
153 | 135 | ||
154 | // Proceed return true if the message is to be processed in derived implementations | 136 | // Proceed return true if the message is to be processed in derived implementations |
155 | func (t *GenericResultHandler) Proceed(ctx context.Context, msg *message.DHTP2PResultMsg) bool { | 137 | func (t *ResultHandler) Proceed(ctx context.Context, msg *message.DHTP2PResultMsg) bool { |
156 | block := blocks.NewGenericBlock(msg.Block) | 138 | blk, err := blocks.NewBlock(enums.BlockType(msg.BType), msg.Expire, msg.Block) |
157 | if !t.resFilter.Contains(block) { | 139 | if err == nil && !t.resFilter.Contains(blk) { |
158 | t.resFilter.Add(block) | 140 | t.resFilter.Add(blk) |
159 | return true | 141 | return true |
160 | } | 142 | } |
161 | return false | 143 | return false |
162 | } | 144 | } |
163 | 145 | ||
164 | //---------------------------------------------------------------------- | ||
165 | // Result handler for forwarded GET requests | ||
166 | //---------------------------------------------------------------------- | ||
167 | |||
168 | // ForwardResultHandler data structure | ||
169 | type ForwardResultHandler struct { | ||
170 | GenericResultHandler | ||
171 | |||
172 | resp transport.Responder // responder for communicating back to originator | ||
173 | } | ||
174 | |||
175 | // NewForwardResultHandler derived from DHT-GET message | ||
176 | func NewForwardResultHandler(msgIn message.Message, rf blocks.ResultFilter, back transport.Responder) *ForwardResultHandler { | ||
177 | // check for correct message type and handler function | ||
178 | msg, ok := msgIn.(*message.DHTP2PGetMsg) | ||
179 | if ok { | ||
180 | return &ForwardResultHandler{ | ||
181 | GenericResultHandler: *NewGenericResultHandler(msg, rf), | ||
182 | resp: back, | ||
183 | } | ||
184 | } | ||
185 | return nil | ||
186 | } | ||
187 | |||
188 | // Handle incoming DHT-P2P-RESULT message | 146 | // Handle incoming DHT-P2P-RESULT message |
189 | func (t *ForwardResultHandler) Handle(ctx context.Context, msg *message.DHTP2PResultMsg, pth *path.Path, sender, local *util.PeerID) bool { | 147 | func (t *ResultHandler) Handle(ctx context.Context, msg *message.DHTP2PResultMsg, pth *path.Path, sender, local *util.PeerID) bool { |
190 | // don't send result if it is filtered out | 148 | // don't send result if it is filtered out |
191 | if !t.Proceed(ctx, msg) { | 149 | if !t.Proceed(ctx, msg) { |
192 | logger.Printf(logger.DBG, "[dht-task-%d] result filtered out -- already known", t.id) | 150 | logger.Printf(logger.DBG, "[dht-task-%d] result filtered out -- already known", t.id) |
193 | return false | 151 | return false |
194 | } | 152 | } |
195 | // extend path if route is recorded | 153 | // check if we are delivering results to remote nodes |
196 | pp := pth.Clone() | 154 | rcv := t.resp.Receiver() |
197 | if msg.Flags&enums.DHT_RO_RECORD_ROUTE != 0 { | 155 | tgt := "locally" |
198 | // yes: add path element for remote receivers | 156 | if rcv != nil { |
199 | if rcv := t.resp.Receiver(); rcv != nil { | 157 | // extend path if route is recorded |
158 | var pp *path.Path | ||
159 | if msg.Flags&enums.DHT_RO_RECORD_ROUTE != 0 { | ||
160 | pp = pth.Clone() | ||
161 | // yes: add path element | ||
200 | pe := pp.NewElement(sender, local, rcv) | 162 | pe := pp.NewElement(sender, local, rcv) |
201 | pp.Add(pe) | 163 | pp.Add(pe) |
202 | } | 164 | } |
165 | // build updated PUT message | ||
166 | msg = msg.Update(pp) | ||
167 | tgt = rcv.Short() | ||
203 | } | 168 | } |
204 | |||
205 | // build updated PUT message | ||
206 | msgOut := msg.Update(pp) | ||
207 | |||
208 | // send result message back to originator (result forwarding). | 169 | // send result message back to originator (result forwarding). |
209 | logger.Printf(logger.INFO, "[dht-task-%d] sending result back to originator", t.id) | 170 | logger.Printf(logger.INFO, "[dht-task-%d] sending result back %s", t.id, tgt) |
210 | if err := t.resp.Send(ctx, msgOut); err != nil && err != transport.ErrEndpMaybeSent { | 171 | if err := t.resp.Send(ctx, msg); err != nil && err != transport.ErrEndpMaybeSent { |
211 | logger.Printf(logger.ERROR, "[dht-task-%d] sending result back to originator failed: %s", t.id, err.Error()) | 172 | logger.Printf(logger.ERROR, "[dht-task-%d] sending result back %s failed: %s", t.id, tgt, err.Error()) |
212 | return false | 173 | return false |
213 | } | 174 | } |
214 | return true | 175 | return true |
215 | } | 176 | } |
216 | 177 | ||
217 | // Compare two forward result filters | ||
218 | func (t *ForwardResultHandler) Compare(h ResultHandler) int { | ||
219 | // check for correct handler type | ||
220 | ht, ok := h.(*ForwardResultHandler) | ||
221 | if !ok { | ||
222 | logger.Println(logger.DBG, "[frh] can't compare apples with oranges") | ||
223 | return RHC_DIFFER | ||
224 | } | ||
225 | // check for same recipient | ||
226 | if ht.resp.Receiver().Equals(t.resp.Receiver()) { | ||
227 | logger.Printf(logger.DBG, "[frh] recipients differ: %s -- %s", ht.resp.Receiver(), t.resp.Receiver()) | ||
228 | return RHC_DIFFER | ||
229 | } | ||
230 | // check generic handler data | ||
231 | return t.GenericResultHandler.Compare(&ht.GenericResultHandler) | ||
232 | } | ||
233 | |||
234 | // Merge two forward result handlers | ||
235 | func (t *ForwardResultHandler) Merge(h ResultHandler) bool { | ||
236 | // check for correct handler type | ||
237 | ht, ok := h.(*ForwardResultHandler) | ||
238 | if !ok { | ||
239 | return false | ||
240 | } | ||
241 | return t.GenericResultHandler.Merge(&ht.GenericResultHandler) | ||
242 | } | ||
243 | |||
244 | //---------------------------------------------------------------------- | ||
245 | // Result handler for locally-initiated GET requests: | ||
246 | // | ||
247 | // Before sending the GET request a handler is added for the request: | ||
248 | // | ||
249 | // rc := make(chan any) | ||
250 | // myRH := NewDirectResultHandler(msg, rf, MyCustomHandler, rc) | ||
251 | // m.reshdlrs.Add(myRH) | ||
252 | // | ||
253 | // If a matching response is received, the custom handler is executed | ||
254 | // in a separate go-routine. A custom handler returns a result (or error) on | ||
255 | // a back channel and should be context-sensitive (termination). | ||
256 | // | ||
257 | // If an asynchronous behaviour is required, use 'ret := <-rc' to wait for | ||
258 | // completion; synchronous execution does not require 'rc' (which can be set | ||
259 | // to nil). | ||
260 | //---------------------------------------------------------------------- | ||
261 | |||
262 | // ResultHandlerFcn is the function prototype for custom handlers: | ||
263 | type ResultHandlerFcn func(context.Context, *message.DHTP2PResultMsg, *path.Path, chan<- any) bool | ||
264 | |||
265 | // DirectResultHandler for local DHT-P2P-GET requests | ||
266 | type DirectResultHandler struct { | ||
267 | GenericResultHandler | ||
268 | |||
269 | hdlr ResultHandlerFcn // Hdlr is a custom message handler | ||
270 | rc chan any // handler result channel | ||
271 | } | ||
272 | |||
273 | // NewDirectResultHandler create a new GET handler instance | ||
274 | func NewDirectResultHandler(msgIn message.Message, rf blocks.ResultFilter, hdlr ResultHandlerFcn, rc chan any) *DirectResultHandler { | ||
275 | // check for correct message type and handler function | ||
276 | msg, ok := msgIn.(*message.DHTP2PGetMsg) | ||
277 | if ok { | ||
278 | return &DirectResultHandler{ | ||
279 | GenericResultHandler: *NewGenericResultHandler(msg, rf), | ||
280 | hdlr: hdlr, | ||
281 | rc: rc, | ||
282 | } | ||
283 | } | ||
284 | return nil | ||
285 | } | ||
286 | |||
287 | // Handle incoming DHT-P2P-RESULT message | ||
288 | func (t *DirectResultHandler) Handle(ctx context.Context, msg *message.DHTP2PResultMsg, pth *path.Path, sender, local *util.PeerID) bool { | ||
289 | // don't send result if it is filtered out | ||
290 | if !t.Proceed(ctx, msg) { | ||
291 | logger.Printf(logger.DBG, "[dht-task-%d] result filtered out -- already known", t.id) | ||
292 | return false | ||
293 | } | ||
294 | // check for correct message type and handler function | ||
295 | if t.hdlr != nil { | ||
296 | logger.Printf(logger.INFO, "[dht-task-%d] handling result message", t.id) | ||
297 | return t.hdlr(ctx, msg, pth, t.rc) | ||
298 | } | ||
299 | return false | ||
300 | } | ||
301 | |||
302 | // Compare two direct result handlers | ||
303 | func (t *DirectResultHandler) Compare(h ResultHandler) int { | ||
304 | // check for correct handler type | ||
305 | ht, ok := h.(*DirectResultHandler) | ||
306 | if !ok { | ||
307 | return RHC_DIFFER | ||
308 | } | ||
309 | // check generic handler data | ||
310 | return t.GenericResultHandler.Compare(&ht.GenericResultHandler) | ||
311 | } | ||
312 | |||
313 | // Merge two direct result handlers | ||
314 | func (t *DirectResultHandler) Merge(h ResultHandler) bool { | ||
315 | // check for correct handler type | ||
316 | ht, ok := h.(*DirectResultHandler) | ||
317 | if !ok { | ||
318 | return false | ||
319 | } | ||
320 | // check generic handler data | ||
321 | return t.GenericResultHandler.Merge(&ht.GenericResultHandler) | ||
322 | } | ||
323 | |||
324 | //---------------------------------------------------------------------- | 178 | //---------------------------------------------------------------------- |
325 | // Handler list for book-keeping: | 179 | // Handler list for book-keeping: |
326 | // * For each query/store key there can be multiple result handlers. | 180 | // * For each query/store key there can be multiple result handlers. |
@@ -328,24 +182,24 @@ func (t *DirectResultHandler) Merge(h ResultHandler) bool { | |||
328 | 182 | ||
329 | // ResultHandlerList holds the currently active tasks | 183 | // ResultHandlerList holds the currently active tasks |
330 | type ResultHandlerList struct { | 184 | type ResultHandlerList struct { |
331 | list *util.Map[string, []ResultHandler] // map of handlers | 185 | list *util.Map[string, []*ResultHandler] // map of handlers |
332 | } | 186 | } |
333 | 187 | ||
334 | // NewResultHandlerList creates a new task list | 188 | // NewResultHandlerList creates a new task list |
335 | func NewResultHandlerList() *ResultHandlerList { | 189 | func NewResultHandlerList() *ResultHandlerList { |
336 | return &ResultHandlerList{ | 190 | return &ResultHandlerList{ |
337 | list: util.NewMap[string, []ResultHandler](), | 191 | list: util.NewMap[string, []*ResultHandler](), |
338 | } | 192 | } |
339 | } | 193 | } |
340 | 194 | ||
341 | // Add handler to list | 195 | // Add handler to list |
342 | func (t *ResultHandlerList) Add(hdlr ResultHandler) bool { | 196 | func (t *ResultHandlerList) Add(hdlr *ResultHandler) bool { |
343 | // get current list of handlers for key | 197 | // get current list of handlers for key |
344 | key := hdlr.Key().String() | 198 | key := hdlr.Key().String() |
345 | list, ok := t.list.Get(key, 0) | 199 | list, ok := t.list.Get(key, 0) |
346 | modified := false | 200 | modified := false |
347 | if !ok { | 201 | if !ok { |
348 | list = make([]ResultHandler, 0) | 202 | list = make([]*ResultHandler, 0) |
349 | } else { | 203 | } else { |
350 | // check if handler is already available | 204 | // check if handler is already available |
351 | loop: | 205 | loop: |
@@ -353,23 +207,23 @@ func (t *ResultHandlerList) Add(hdlr ResultHandler) bool { | |||
353 | switch h.Compare(hdlr) { | 207 | switch h.Compare(hdlr) { |
354 | case RHC_SAME: | 208 | case RHC_SAME: |
355 | // already in list; no need to add again | 209 | // already in list; no need to add again |
356 | logger.Println(logger.DBG, "[rhl] SAME") | 210 | logger.Println(logger.DBG, "[rhl] resultfilter compare: SAME") |
357 | return false | 211 | return false |
358 | case RHC_MERGE: | 212 | case RHC_MERGE: |
359 | // merge the two result handlers | 213 | // merge the two result handlers |
360 | oldMod := modified | 214 | oldMod := modified |
361 | modified = h.Merge(hdlr) || modified | 215 | modified = h.Merge(hdlr) || modified |
362 | logger.Printf(logger.DBG, "[rhl] MERGE (%v -- %v)", oldMod, modified) | 216 | logger.Printf(logger.DBG, "[rhl] resultfilter compare: MERGE (%v -- %v)", oldMod, modified) |
363 | break loop | 217 | break loop |
364 | case RHC_REPLACE: | 218 | case RHC_REPLACE: |
365 | // replace the old handler with the new one | 219 | // replace the old handler with the new one |
366 | logger.Println(logger.DBG, "[rhl] REPLACE") | 220 | logger.Printf(logger.DBG, "[rhl] resultfilter compare: REPLACE #%d with #%d", list[i].id, hdlr.id) |
367 | list[i] = hdlr | 221 | list[i] = hdlr |
368 | modified = true | 222 | modified = true |
369 | break loop | 223 | break loop |
370 | case RHC_DIFFER: | 224 | case RHC_DIFFER: |
371 | // try next | 225 | // try next |
372 | logger.Println(logger.DBG, "[rhl] DIFFER") | 226 | logger.Println(logger.DBG, "[rhl] resultfilter compare: DIFFER") |
373 | } | 227 | } |
374 | } | 228 | } |
375 | } | 229 | } |
@@ -382,14 +236,14 @@ func (t *ResultHandlerList) Add(hdlr ResultHandler) bool { | |||
382 | } | 236 | } |
383 | 237 | ||
384 | // Get handler list for given key | 238 | // Get handler list for given key |
385 | func (t *ResultHandlerList) Get(key string) ([]ResultHandler, bool) { | 239 | func (t *ResultHandlerList) Get(key string) ([]*ResultHandler, bool) { |
386 | return t.list.Get(key, 0) | 240 | return t.list.Get(key, 0) |
387 | } | 241 | } |
388 | 242 | ||
389 | // Cleanup removes expired tasks from list | 243 | // Cleanup removes expired tasks from list |
390 | func (t *ResultHandlerList) Cleanup() { | 244 | func (t *ResultHandlerList) Cleanup() { |
391 | err := t.list.ProcessRange(func(key string, list []ResultHandler, pid int) error { | 245 | err := t.list.ProcessRange(func(key string, list []*ResultHandler, pid int) error { |
392 | var newList []ResultHandler | 246 | var newList []*ResultHandler |
393 | changed := false | 247 | changed := false |
394 | for _, rh := range list { | 248 | for _, rh := range list { |
395 | if !rh.Done() { | 249 | if !rh.Done() { |
@@ -404,6 +258,6 @@ func (t *ResultHandlerList) Cleanup() { | |||
404 | return nil | 258 | return nil |
405 | }, false) | 259 | }, false) |
406 | if err != nil { | 260 | if err != nil { |
407 | logger.Printf(logger.ERROR, "[ResultHandlerList] clean-up error: %s", err.Error()) | 261 | logger.Printf(logger.ERROR, "[rh-list] clean-up error: %s", err.Error()) |
408 | } | 262 | } |
409 | } | 263 | } |
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 { | |||
66 | func NewQueryAddress(key *crypto.HashCode) *PeerAddress { | 66 | func NewQueryAddress(key *crypto.HashCode) *PeerAddress { |
67 | return &PeerAddress{ | 67 | return &PeerAddress{ |
68 | Peer: nil, | 68 | Peer: nil, |
69 | Key: crypto.NewHashCode(key.Bits), | 69 | Key: crypto.NewHashCode(key.Data), |
70 | lastSeen: util.AbsoluteTimeNow(), | 70 | lastSeen: util.AbsoluteTimeNow(), |
71 | lastUsed: util.AbsoluteTimeNow(), | 71 | lastUsed: util.AbsoluteTimeNow(), |
72 | } | 72 | } |
@@ -74,18 +74,18 @@ func NewQueryAddress(key *crypto.HashCode) *PeerAddress { | |||
74 | 74 | ||
75 | // String returns a human-readble representation of an address. | 75 | // String returns a human-readble representation of an address. |
76 | func (addr *PeerAddress) String() string { | 76 | func (addr *PeerAddress) String() string { |
77 | return hex.EncodeToString(addr.Key.Bits) | 77 | return hex.EncodeToString(addr.Key.Data) |
78 | } | 78 | } |
79 | 79 | ||
80 | // Equals returns true if two peer addresses are the same. | 80 | // Equal returns true if two peer addresses are the same. |
81 | func (addr *PeerAddress) Equals(p *PeerAddress) bool { | 81 | func (addr *PeerAddress) Equal(p *PeerAddress) bool { |
82 | return bytes.Equal(addr.Key.Bits, p.Key.Bits) | 82 | return bytes.Equal(addr.Key.Data, p.Key.Data) |
83 | } | 83 | } |
84 | 84 | ||
85 | // Distance between two addresses: returns a distance value and a | 85 | // Distance between two addresses: returns a distance value and a |
86 | // bucket index (smaller index = less distant). | 86 | // bucket index (smaller index = less distant). |
87 | func (addr *PeerAddress) Distance(p *PeerAddress) (*math.Int, int) { | 87 | func (addr *PeerAddress) Distance(p *PeerAddress) (*math.Int, int) { |
88 | r := util.Distance(addr.Key.Bits, p.Key.Bits) | 88 | r := util.Distance(addr.Key.Data, p.Key.Data) |
89 | return r, 512 - r.BitLen() | 89 | return r, 512 - r.BitLen() |
90 | } | 90 | } |
91 | 91 | ||
@@ -136,24 +136,22 @@ func NewRoutingTable(ref *PeerAddress, cfg *config.RoutingConfig) *RoutingTable | |||
136 | // Returns true if the entry was added, false otherwise. | 136 | // Returns true if the entry was added, false otherwise. |
137 | func (rt *RoutingTable) Add(p *PeerAddress, label string) bool { | 137 | func (rt *RoutingTable) Add(p *PeerAddress, label string) bool { |
138 | k := p.String() | 138 | k := p.String() |
139 | logger.Printf(logger.DBG, "[%s] Add(%s)", label, k) | ||
140 | 139 | ||
141 | // check if peer is already known | 140 | // check if peer is already known |
142 | if px, ok := rt.list.Get(k, 0); ok { | 141 | if px, ok := rt.list.Get(k, 0); ok { |
143 | logger.Printf(logger.DBG, "[%s] --> already known", label) | ||
144 | px.lastSeen = util.AbsoluteTimeNow() | 142 | px.lastSeen = util.AbsoluteTimeNow() |
145 | return false | 143 | return false |
146 | } | 144 | } |
147 | // compute distance (bucket index) and insert address. | 145 | // compute distance (bucket index) and insert address. |
148 | _, idx := p.Distance(rt.ref) | 146 | _, idx := p.Distance(rt.ref) |
149 | if rt.buckets[idx].Add(p) { | 147 | if rt.buckets[idx].Add(p) { |
150 | logger.Printf(logger.DBG, "[%s] --> entry added", label) | ||
151 | p.lastUsed = util.AbsoluteTimeNow() | 148 | p.lastUsed = util.AbsoluteTimeNow() |
152 | rt.list.Put(k, p, 0) | 149 | rt.list.Put(k, p, 0) |
150 | logger.Printf(logger.INFO, "[%s] %s added to routing table", | ||
151 | label, p.Peer.Short()) | ||
153 | return true | 152 | return true |
154 | } | 153 | } |
155 | // Full bucket: we did not add the address to the routing table. | 154 | // Full bucket: we did not add the address to the routing table. |
156 | logger.Printf(logger.DBG, "[%s] --> bucket[%d] full -- discarded", label, idx) | ||
157 | return false | 155 | return false |
158 | } | 156 | } |
159 | 157 | ||
@@ -178,41 +176,39 @@ func (rt *RoutingTable) Check(p *PeerAddress) int { | |||
178 | 176 | ||
179 | // Remove peer address from routing table. | 177 | // Remove peer address from routing table. |
180 | // Returns true if the entry was removed, false otherwise. | 178 | // Returns true if the entry was removed, false otherwise. |
181 | func (rt *RoutingTable) Remove(p *PeerAddress, pid int) bool { | 179 | func (rt *RoutingTable) Remove(p *PeerAddress, label string, pid int) bool { |
182 | k := p.String() | ||
183 | logger.Printf(logger.DBG, "[RT] Remove(%s)", k) | ||
184 | |||
185 | // compute distance (bucket index) and remove entry from bucket | 180 | // compute distance (bucket index) and remove entry from bucket |
186 | rc := false | 181 | rc := false |
187 | _, idx := p.Distance(rt.ref) | 182 | _, idx := p.Distance(rt.ref) |
188 | if rt.buckets[idx].Remove(p) { | 183 | if rt.buckets[idx].Remove(p) { |
189 | logger.Println(logger.DBG, "[RT] --> entry removed from bucket and internal lists") | 184 | logger.Printf(logger.DBG, "[%s] %s removed from RT (bucket and internal lists)", label, p.Peer.Short()) |
190 | rc = true | 185 | rc = true |
191 | } else { | 186 | } else { |
192 | // remove from internal list | 187 | // remove from internal list |
193 | logger.Println(logger.DBG, "[RT] --> entry removed from internal lists only") | 188 | logger.Printf(logger.DBG, "[%s] %s removed from RT (internal lists only)", label, p.Peer.Short()) |
194 | } | 189 | } |
195 | rt.list.Delete(k, 0) | 190 | rt.list.Delete(p.String(), 0) |
196 | // delete from HELLO cache | 191 | // delete from HELLO cache |
197 | rt.helloCache.Delete(p.Peer.String(), pid) | 192 | rt.helloCache.Delete(p.Peer.String(), pid) |
198 | return rc | 193 | return rc |
199 | } | 194 | } |
200 | 195 | ||
201 | // Contains checks if a peer is available in the routing table | 196 | // Contains checks if a peer is available in the routing table |
202 | func (rt *RoutingTable) Contains(p *PeerAddress) bool { | 197 | func (rt *RoutingTable) Contains(p *PeerAddress, label string) bool { |
203 | k := p.String() | 198 | k := p.String() |
204 | logger.Printf(logger.DBG, "[RT] Contains(%s)?", k) | ||
205 | 199 | ||
206 | // check for peer in internal list | 200 | // check for peer in internal list |
207 | px, ok := rt.list.Get(k, 0) | 201 | px, ok := rt.list.Get(k, 0) |
208 | if !ok { | 202 | if !ok { |
209 | logger.Println(logger.DBG, "[RT] --> NOT found in current list:") | 203 | logger.Printf(logger.WARN, "[%s] %s NOT found in RT", label, p.Peer.Short()) |
204 | var list []string | ||
210 | _ = rt.list.ProcessRange(func(key string, val *PeerAddress, _ int) error { | 205 | _ = rt.list.ProcessRange(func(key string, val *PeerAddress, _ int) error { |
211 | logger.Printf(logger.DBG, "[RT] * %s", val) | 206 | list = append(list, val.Peer.Short()) |
212 | return nil | 207 | return nil |
213 | }, true) | 208 | }, true) |
209 | logger.Printf(logger.DBG, "[%s] RT=%v", list) | ||
214 | } else { | 210 | } else { |
215 | logger.Println(logger.DBG, "[RT] --> found in current list") | 211 | //logger.Println(logger.DBG, "[RT] --> found in current list") |
216 | px.lastSeen = util.AbsoluteTimeNow() | 212 | px.lastSeen = util.AbsoluteTimeNow() |
217 | } | 213 | } |
218 | return ok | 214 | return ok |
@@ -310,7 +306,7 @@ func (rt *RoutingTable) IsClosestPeer(p, k *PeerAddress, pf *blocks.PeerFilter, | |||
310 | return d1.Cmp(d0) < 0 | 306 | return d1.Cmp(d0) < 0 |
311 | } | 307 | } |
312 | // check if p is closest peer | 308 | // check if p is closest peer |
313 | return n.Equals(p) | 309 | return n.Equal(p) |
314 | } | 310 | } |
315 | 311 | ||
316 | // ComputeOutDegree computes the number of neighbors that a message should be forwarded to. | 312 | // 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 { | |||
340 | func (rt *RoutingTable) heartbeat(ctx context.Context) { | 336 | func (rt *RoutingTable) heartbeat(ctx context.Context) { |
341 | 337 | ||
342 | // check for dead or expired peers | 338 | // check for dead or expired peers |
343 | logger.Println(logger.DBG, "[dht] RT heartbeat...") | 339 | logger.Println(logger.DBG, "[dht-rt-hb] RT heartbeat...") |
344 | timeout := util.NewRelativeTime(time.Duration(rt.cfg.PeerTTL) * time.Second) | 340 | timeout := util.NewRelativeTime(time.Duration(rt.cfg.PeerTTL) * time.Second) |
345 | if err := rt.list.ProcessRange(func(k string, p *PeerAddress, pid int) error { | 341 | if err := rt.list.ProcessRange(func(k string, p *PeerAddress, pid int) error { |
346 | // check if we can/need to drop a peer | 342 | // check if we can/need to drop a peer |
347 | drop := timeout.Compare(p.lastSeen.Elapsed()) < 0 | 343 | drop := timeout.Compare(p.lastSeen.Elapsed()) < 0 |
348 | if drop || timeout.Compare(p.lastUsed.Elapsed()) < 0 { | 344 | if drop || timeout.Compare(p.lastUsed.Elapsed()) < 0 { |
349 | logger.Printf(logger.DBG, "[RT] removing %v: %v, %v", p, p.lastSeen.Elapsed(), p.lastUsed.Elapsed()) | 345 | logger.Printf(logger.DBG, "[dht-rt-hb] removing %v: %v, %v", p, p.lastSeen.Elapsed(), p.lastUsed.Elapsed()) |
350 | rt.Remove(p, pid) | 346 | rt.Remove(p, "dht-rt-hb", pid) |
351 | } | 347 | } |
352 | return nil | 348 | return nil |
353 | }, false); err != nil { | 349 | }, false); err != nil { |
354 | logger.Println(logger.ERROR, "[dht] RT heartbeat failed: "+err.Error()) | 350 | logger.Println(logger.ERROR, "[dht-rt-hb] RT heartbeat failed: "+err.Error()) |
355 | } | 351 | } |
356 | 352 | ||
357 | // drop expired entries from the HELLO cache | 353 | // drop expired entries from the HELLO cache |
358 | _ = rt.helloCache.ProcessRange(func(key string, val *blocks.HelloBlock, pid int) error { | 354 | _ = rt.helloCache.ProcessRange(func(key string, val *blocks.HelloBlock, pid int) error { |
359 | if val.Expires.Expired() { | 355 | if val.Expire_.Expired() { |
360 | rt.helloCache.Delete(key, pid) | 356 | rt.helloCache.Delete(key, pid) |
361 | } | 357 | } |
362 | return nil | 358 | return nil |
@@ -369,7 +365,7 @@ func (rt *RoutingTable) heartbeat(ctx context.Context) { | |||
369 | //---------------------------------------------------------------------- | 365 | //---------------------------------------------------------------------- |
370 | 366 | ||
371 | // LookupHello returns blocks from the HELLO cache for given query. | 367 | // LookupHello returns blocks from the HELLO cache for given query. |
372 | func (rt *RoutingTable) LookupHello(addr *PeerAddress, rf blocks.ResultFilter, approx bool) (results []*store.DHTResult) { | 368 | func (rt *RoutingTable) LookupHello(addr *PeerAddress, rf blocks.ResultFilter, approx bool, label string) (results []*store.DHTResult) { |
373 | // iterate over cached HELLOs to find matches; | 369 | // iterate over cached HELLOs to find matches; |
374 | // approximate search is limited by distance (max. diff for bucket index is 16) | 370 | // approximate search is limited by distance (max. diff for bucket index is 16) |
375 | _ = rt.helloCache.ProcessRange(func(key string, hb *blocks.HelloBlock, _ int) error { | 371 | _ = 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 | |||
390 | results = append(results, result) | 386 | results = append(results, result) |
391 | } | 387 | } |
392 | } else { | 388 | } else { |
393 | logger.Printf(logger.DBG, "[RT] GET-HELLO: cache block is filtered") | 389 | logger.Printf(logger.DBG, "[%s] LookupHello: cached HELLO block is filtered") |
394 | } | 390 | } |
395 | return nil | 391 | return nil |
396 | }, true) | 392 | }, true) |
@@ -479,7 +475,7 @@ func (b *Bucket) Remove(p *PeerAddress) bool { | |||
479 | defer b.Unlock() | 475 | defer b.Unlock() |
480 | 476 | ||
481 | for i, pe := range b.list { | 477 | for i, pe := range b.list { |
482 | if pe.Equals(p) { | 478 | if pe.Equal(p) { |
483 | // found entry: remove it | 479 | // found entry: remove it |
484 | b.list = append(b.list[:i], b.list[i+1:]...) | 480 | b.list = append(b.list[:i], b.list[i+1:]...) |
485 | return true | 481 | 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) { | |||
101 | t.Logf("[%6d] %s %s\n", e, task.addr, msg) | 101 | t.Logf("[%6d] %s %s\n", e, task.addr, msg) |
102 | } | 102 | } |
103 | disconnected := func(task *Entry, e int64, msg string) { | 103 | disconnected := func(task *Entry, e int64, msg string) { |
104 | rt.Remove(task.addr, 0) | 104 | rt.Remove(task.addr, "test", 0) |
105 | task.online = false | 105 | task.online = false |
106 | task.last = e | 106 | task.last = e |
107 | t.Logf("[%6d] %s %s\n", e, task.addr, msg) | 107 | 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: | |||
83 | logger.Printf(logger.INFO, "[dht:%d:%d] Received request: %v\n", id, reqID, msg) | 83 | logger.Printf(logger.INFO, "[dht:%d:%d] Received request: %v\n", id, reqID, msg) |
84 | 84 | ||
85 | // handle message | 85 | // handle message |
86 | valueCtx := context.WithValue(ctx, service.CtxKey("label"), fmt.Sprintf(":%d:%d", id, reqID)) | 86 | valueCtx := context.WithValue(ctx, core.CtxKey("label"), fmt.Sprintf(":%d:%d", id, reqID)) |
87 | s.HandleMessage(valueCtx, nil, msg, mc) | 87 | s.HandleMessage(valueCtx, nil, msg, mc) |
88 | } | 88 | } |
89 | // close client connection | 89 | // 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 | |||
132 | continue | 132 | continue |
133 | } | 133 | } |
134 | // check for expired record | 134 | // check for expired record |
135 | if rec.Expires.Expired() { | 135 | if rec.Expire.Expired() { |
136 | // do we have an associated shadow record? | 136 | // do we have an associated shadow record? |
137 | for _, shadow := range shadows { | 137 | for _, shadow := range shadows { |
138 | if shadow.Type == rec.Type && !shadow.Expires.Expired() { | 138 | if shadow.RType == rec.RType && !shadow.Expire.Expired() { |
139 | // deliver un-expired shadow record instead. | 139 | // deliver un-expired shadow record instead. |
140 | shadow.Flags &^= uint32(enums.GNS_FLAG_SHADOW) | 140 | shadow.Flags &^= uint32(enums.GNS_FLAG_SHADOW) |
141 | active = append(active, shadow) | 141 | active = append(active, shadow) |
@@ -153,7 +153,7 @@ func NewBlockHandlerList(records []*message.ResourceRecord, labels []string) (*B | |||
153 | logger.Printf(logger.DBG, "[gns] handler_list: skip %v\n", rec) | 153 | logger.Printf(logger.DBG, "[gns] handler_list: skip %v\n", rec) |
154 | continue | 154 | continue |
155 | } | 155 | } |
156 | rrType := enums.GNSType(rec.Type) | 156 | rrType := enums.GNSType(rec.RType) |
157 | hl.counts.Add(rrType) | 157 | hl.counts.Add(rrType) |
158 | 158 | ||
159 | // check for custom handler type | 159 | // check for custom handler type |
@@ -224,12 +224,12 @@ type ZoneKeyHandler struct { | |||
224 | // NewZoneHandler returns a new BlockHandler instance | 224 | // NewZoneHandler returns a new BlockHandler instance |
225 | func NewZoneHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, error) { | 225 | func NewZoneHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, error) { |
226 | // check if we have an implementation for the zone type | 226 | // check if we have an implementation for the zone type |
227 | if crypto.GetImplementation(rec.Type) == nil { | 227 | if crypto.GetImplementation(rec.RType) == nil { |
228 | return nil, ErrInvalidRecordType | 228 | return nil, ErrInvalidRecordType |
229 | } | 229 | } |
230 | // assemble handler | 230 | // assemble handler |
231 | h := &ZoneKeyHandler{ | 231 | h := &ZoneKeyHandler{ |
232 | ztype: rec.Type, | 232 | ztype: rec.RType, |
233 | zkey: nil, | 233 | zkey: nil, |
234 | } | 234 | } |
235 | // add the record to the handler | 235 | // add the record to the handler |
@@ -242,7 +242,7 @@ func NewZoneHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, | |||
242 | // AddRecord inserts a PKEY record into the handler. | 242 | // AddRecord inserts a PKEY record into the handler. |
243 | func (h *ZoneKeyHandler) AddRecord(rec *message.ResourceRecord, labels []string) (err error) { | 243 | func (h *ZoneKeyHandler) AddRecord(rec *message.ResourceRecord, labels []string) (err error) { |
244 | // check record type | 244 | // check record type |
245 | if rec.Type != h.ztype { | 245 | if rec.RType != h.ztype { |
246 | return ErrInvalidRecordType | 246 | return ErrInvalidRecordType |
247 | } | 247 | } |
248 | // check for sole zone key record in block | 248 | // check for sole zone key record in block |
@@ -292,7 +292,7 @@ type Gns2DnsHandler struct { | |||
292 | 292 | ||
293 | // NewGns2DnsHandler returns a new BlockHandler instance | 293 | // NewGns2DnsHandler returns a new BlockHandler instance |
294 | func NewGns2DnsHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, error) { | 294 | func NewGns2DnsHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, error) { |
295 | if enums.GNSType(rec.Type) != enums.GNS_TYPE_GNS2DNS { | 295 | if enums.GNSType(rec.RType) != enums.GNS_TYPE_GNS2DNS { |
296 | return nil, ErrInvalidRecordType | 296 | return nil, ErrInvalidRecordType |
297 | } | 297 | } |
298 | h := &Gns2DnsHandler{ | 298 | h := &Gns2DnsHandler{ |
@@ -308,7 +308,7 @@ func NewGns2DnsHandler(rec *message.ResourceRecord, labels []string) (BlockHandl | |||
308 | 308 | ||
309 | // AddRecord inserts a GNS2DNS record into the handler. | 309 | // AddRecord inserts a GNS2DNS record into the handler. |
310 | func (h *Gns2DnsHandler) AddRecord(rec *message.ResourceRecord, labels []string) error { | 310 | func (h *Gns2DnsHandler) AddRecord(rec *message.ResourceRecord, labels []string) error { |
311 | if enums.GNSType(rec.Type) != enums.GNS_TYPE_GNS2DNS { | 311 | if enums.GNSType(rec.RType) != enums.GNS_TYPE_GNS2DNS { |
312 | return ErrInvalidRecordType | 312 | return ErrInvalidRecordType |
313 | } | 313 | } |
314 | logger.Printf(logger.DBG, "[gns] GNS2DNS data: %s\n", hex.EncodeToString(rec.Data)) | 314 | logger.Printf(logger.DBG, "[gns] GNS2DNS data: %s\n", hex.EncodeToString(rec.Data)) |
@@ -367,7 +367,7 @@ type BoxHandler struct { | |||
367 | 367 | ||
368 | // NewBoxHandler returns a new BlockHandler instance | 368 | // NewBoxHandler returns a new BlockHandler instance |
369 | func NewBoxHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, error) { | 369 | func NewBoxHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, error) { |
370 | if enums.GNSType(rec.Type) != enums.GNS_TYPE_BOX { | 370 | if enums.GNSType(rec.RType) != enums.GNS_TYPE_BOX { |
371 | return nil, ErrInvalidRecordType | 371 | return nil, ErrInvalidRecordType |
372 | } | 372 | } |
373 | h := &BoxHandler{ | 373 | h := &BoxHandler{ |
@@ -381,7 +381,7 @@ func NewBoxHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, | |||
381 | 381 | ||
382 | // AddRecord inserts a BOX record into the handler. | 382 | // AddRecord inserts a BOX record into the handler. |
383 | func (h *BoxHandler) AddRecord(rec *message.ResourceRecord, labels []string) error { | 383 | func (h *BoxHandler) AddRecord(rec *message.ResourceRecord, labels []string) error { |
384 | if enums.GNSType(rec.Type) != enums.GNS_TYPE_BOX { | 384 | if enums.GNSType(rec.RType) != enums.GNS_TYPE_BOX { |
385 | return ErrInvalidRecordType | 385 | return ErrInvalidRecordType |
386 | } | 386 | } |
387 | logger.Printf(logger.DBG, "[box-rr] for labels %v\n", labels) | 387 | logger.Printf(logger.DBG, "[box-rr] for labels %v\n", labels) |
@@ -417,9 +417,9 @@ func (h *BoxHandler) Records(kind RRTypeList) *message.RecordSet { | |||
417 | if kind.HasType(enums.GNSType(box.Type)) { | 417 | if kind.HasType(enums.GNSType(box.Type)) { |
418 | // valid box found: assemble new resource record. | 418 | // valid box found: assemble new resource record. |
419 | rr := new(message.ResourceRecord) | 419 | rr := new(message.ResourceRecord) |
420 | rr.Expires = box.rec.Expires | 420 | rr.Expire = box.rec.Expire |
421 | rr.Flags = box.rec.Flags | 421 | rr.Flags = box.rec.Flags |
422 | rr.Type = box.Type | 422 | rr.RType = box.Type |
423 | rr.Size = uint32(len(box.RR)) | 423 | rr.Size = uint32(len(box.RR)) |
424 | rr.Data = box.RR | 424 | rr.Data = box.RR |
425 | rs.AddRecord(rr) | 425 | rs.AddRecord(rr) |
@@ -445,7 +445,7 @@ type LehoHandler struct { | |||
445 | 445 | ||
446 | // NewLehoHandler returns a new BlockHandler instance | 446 | // NewLehoHandler returns a new BlockHandler instance |
447 | func NewLehoHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, error) { | 447 | func NewLehoHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, error) { |
448 | if enums.GNSType(rec.Type) != enums.GNS_TYPE_LEHO { | 448 | if enums.GNSType(rec.RType) != enums.GNS_TYPE_LEHO { |
449 | return nil, ErrInvalidRecordType | 449 | return nil, ErrInvalidRecordType |
450 | } | 450 | } |
451 | h := &LehoHandler{ | 451 | h := &LehoHandler{ |
@@ -459,7 +459,7 @@ func NewLehoHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, | |||
459 | 459 | ||
460 | // AddRecord inserts a LEHO record into the handler. | 460 | // AddRecord inserts a LEHO record into the handler. |
461 | func (h *LehoHandler) AddRecord(rec *message.ResourceRecord, labels []string) error { | 461 | func (h *LehoHandler) AddRecord(rec *message.ResourceRecord, labels []string) error { |
462 | if enums.GNSType(rec.Type) != enums.GNS_TYPE_LEHO { | 462 | if enums.GNSType(rec.RType) != enums.GNS_TYPE_LEHO { |
463 | return ErrInvalidRecordType | 463 | return ErrInvalidRecordType |
464 | } | 464 | } |
465 | h.name = string(rec.Data) | 465 | h.name = string(rec.Data) |
@@ -500,7 +500,7 @@ type CnameHandler struct { | |||
500 | 500 | ||
501 | // NewCnameHandler returns a new BlockHandler instance | 501 | // NewCnameHandler returns a new BlockHandler instance |
502 | func NewCnameHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, error) { | 502 | func NewCnameHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, error) { |
503 | if enums.GNSType(rec.Type) != enums.GNS_TYPE_DNS_CNAME { | 503 | if enums.GNSType(rec.RType) != enums.GNS_TYPE_DNS_CNAME { |
504 | return nil, ErrInvalidRecordType | 504 | return nil, ErrInvalidRecordType |
505 | } | 505 | } |
506 | h := &CnameHandler{ | 506 | h := &CnameHandler{ |
@@ -514,7 +514,7 @@ func NewCnameHandler(rec *message.ResourceRecord, labels []string) (BlockHandler | |||
514 | 514 | ||
515 | // AddRecord inserts a CNAME record into the handler. | 515 | // AddRecord inserts a CNAME record into the handler. |
516 | func (h *CnameHandler) AddRecord(rec *message.ResourceRecord, labels []string) error { | 516 | func (h *CnameHandler) AddRecord(rec *message.ResourceRecord, labels []string) error { |
517 | if enums.GNSType(rec.Type) != enums.GNS_TYPE_DNS_CNAME { | 517 | if enums.GNSType(rec.RType) != enums.GNS_TYPE_DNS_CNAME { |
518 | return ErrInvalidRecordType | 518 | return ErrInvalidRecordType |
519 | } | 519 | } |
520 | if h.rec != nil { | 520 | if h.rec != nil { |
@@ -557,7 +557,7 @@ type VpnHandler struct { | |||
557 | 557 | ||
558 | // NewVpnHandler returns a new BlockHandler instance | 558 | // NewVpnHandler returns a new BlockHandler instance |
559 | func NewVpnHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, error) { | 559 | func NewVpnHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, error) { |
560 | if enums.GNSType(rec.Type) != enums.GNS_TYPE_VPN { | 560 | if enums.GNSType(rec.RType) != enums.GNS_TYPE_VPN { |
561 | return nil, ErrInvalidRecordType | 561 | return nil, ErrInvalidRecordType |
562 | } | 562 | } |
563 | h := &VpnHandler{} | 563 | h := &VpnHandler{} |
@@ -569,7 +569,7 @@ func NewVpnHandler(rec *message.ResourceRecord, labels []string) (BlockHandler, | |||
569 | 569 | ||
570 | // AddRecord inserts a VPN record into the handler. | 570 | // AddRecord inserts a VPN record into the handler. |
571 | func (h *VpnHandler) AddRecord(rec *message.ResourceRecord, labels []string) error { | 571 | func (h *VpnHandler) AddRecord(rec *message.ResourceRecord, labels []string) error { |
572 | if enums.GNSType(rec.Type) != enums.GNS_TYPE_VPN { | 572 | if enums.GNSType(rec.RType) != enums.GNS_TYPE_VPN { |
573 | return ErrInvalidRecordType | 573 | return ErrInvalidRecordType |
574 | } | 574 | } |
575 | if h.rec != nil { | 575 | 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 | |||
176 | // create a new GNS resource record | 176 | // create a new GNS resource record |
177 | rr := new(message.ResourceRecord) | 177 | rr := new(message.ResourceRecord) |
178 | expires := time.Now().Add(time.Duration(record.Header().Ttl) * time.Second) | 178 | expires := time.Now().Add(time.Duration(record.Header().Ttl) * time.Second) |
179 | rr.Expires = util.NewAbsoluteTime(expires) | 179 | rr.Expire = util.NewAbsoluteTime(expires) |
180 | rr.Flags = 0 | 180 | rr.Flags = 0 |
181 | rr.Type = uint32(record.Header().Rrtype) | 181 | rr.RType = uint32(record.Header().Rrtype) |
182 | rr.Size = uint32(record.Header().Rdlength) | 182 | rr.Size = uint32(record.Header().Rdlength) |
183 | rr.Data = make([]byte, rr.Size) | 183 | rr.Data = make([]byte, rr.Size) |
184 | 184 | ||
@@ -230,7 +230,7 @@ func (m *Module) ResolveDNS( | |||
230 | // traverse resource records for 'A' and 'AAAA' records. | 230 | // traverse resource records for 'A' and 'AAAA' records. |
231 | rec_loop: | 231 | rec_loop: |
232 | for _, rec := range set.Records { | 232 | for _, rec := range set.Records { |
233 | switch enums.GNSType(rec.Type) { | 233 | switch enums.GNSType(rec.RType) { |
234 | case enums.GNS_TYPE_DNS_AAAA: | 234 | case enums.GNS_TYPE_DNS_AAAA: |
235 | addr = net.IP(rec.Data) | 235 | addr = net.IP(rec.Data) |
236 | // we prefer IPv6 | 236 | // 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) { | |||
113 | // Filter returns the event filter for the service | 113 | // Filter returns the event filter for the service |
114 | func (m *Module) Filter() *core.EventFilter { | 114 | func (m *Module) Filter() *core.EventFilter { |
115 | f := core.NewEventFilter() | 115 | f := core.NewEventFilter() |
116 | f.AddMsgType(message.GNS_LOOKUP) | 116 | f.AddMsgType(enums.MSG_GNS_LOOKUP) |
117 | f.AddMsgType(message.GNS_LOOKUP_RESULT) | 117 | f.AddMsgType(enums.MSG_GNS_LOOKUP_RESULT) |
118 | f.AddMsgType(message.GNS_REVERSE_LOOKUP) | 118 | f.AddMsgType(enums.MSG_GNS_REVERSE_LOOKUP) |
119 | f.AddMsgType(message.GNS_REVERSE_LOOKUP_RESULT) | 119 | f.AddMsgType(enums.MSG_GNS_REVERSE_LOOKUP_RESULT) |
120 | return f | 120 | return f |
121 | } | 121 | } |
122 | 122 | ||
@@ -299,8 +299,8 @@ func (m *Module) ResolveRelative( | |||
299 | // the longest-living record in the current set. | 299 | // the longest-living record in the current set. |
300 | expires := util.AbsoluteTimeNow() | 300 | expires := util.AbsoluteTimeNow() |
301 | for _, rec := range set.Records { | 301 | for _, rec := range set.Records { |
302 | if rec.Expires.Compare(expires) > 0 { | 302 | if rec.Expire.Compare(expires) > 0 { |
303 | expires = rec.Expires | 303 | expires = rec.Expire |
304 | } | 304 | } |
305 | } | 305 | } |
306 | set.Records = append(set.Records, m.newLEHORecord(inst.Query, expires)) | 306 | set.Records = append(set.Records, m.newLEHORecord(inst.Query, expires)) |
@@ -340,7 +340,7 @@ func (m *Module) ResolveRelative( | |||
340 | set = message.NewRecordSet() | 340 | set = message.NewRecordSet() |
341 | for _, rec := range records { | 341 | for _, rec := range records { |
342 | // is this the record type we are looking for? | 342 | // is this the record type we are looking for? |
343 | if kind.HasType(enums.GNSType(rec.Type)) { | 343 | if kind.HasType(enums.GNSType(rec.RType)) { |
344 | // add it to the result | 344 | // add it to the result |
345 | if rec = hdlrs.FinalizeRecord(rec); rec != nil { | 345 | if rec = hdlrs.FinalizeRecord(rec); rec != nil { |
346 | set.AddRecord(rec) | 346 | set.AddRecord(rec) |
@@ -363,7 +363,7 @@ func (m *Module) ResolveRelative( | |||
363 | // asking for explicitly. | 363 | // asking for explicitly. |
364 | if set.Count > 0 { | 364 | if set.Count > 0 { |
365 | for _, rec := range records { | 365 | for _, rec := range records { |
366 | if !kind.HasType(enums.GNSType(rec.Type)) && (int(rec.Flags)&enums.GNS_FLAG_SUPPL) != 0 { | 366 | if !kind.HasType(enums.GNSType(rec.RType)) && (int(rec.Flags)&enums.GNS_FLAG_SUPPL) != 0 { |
367 | set.AddRecord(rec) | 367 | set.AddRecord(rec) |
368 | } | 368 | } |
369 | } | 369 | } |
@@ -472,9 +472,9 @@ func (m *Module) Lookup( | |||
472 | // newLEHORecord creates a new supplemental GNS record of type LEHO. | 472 | // newLEHORecord creates a new supplemental GNS record of type LEHO. |
473 | func (m *Module) newLEHORecord(name string, expires util.AbsoluteTime) *message.ResourceRecord { | 473 | func (m *Module) newLEHORecord(name string, expires util.AbsoluteTime) *message.ResourceRecord { |
474 | rr := new(message.ResourceRecord) | 474 | rr := new(message.ResourceRecord) |
475 | rr.Expires = expires | 475 | rr.Expire = expires |
476 | rr.Flags = uint32(enums.GNS_FLAG_SUPPL) | 476 | rr.Flags = uint32(enums.GNS_FLAG_SUPPL) |
477 | rr.Type = uint32(enums.GNS_TYPE_LEHO) | 477 | rr.RType = uint32(enums.GNS_TYPE_LEHO) |
478 | rr.Size = uint32(len(name) + 1) | 478 | rr.Size = uint32(len(name) + 1) |
479 | rr.Data = make([]byte, rr.Size) | 479 | rr.Data = make([]byte, rr.Size) |
480 | copy(rr.Data, []byte(name)) | 480 | 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 | |||
96 | logger.Printf(logger.INFO, "[gns:%d:%d] Received request: %v\n", id, reqID, msg) | 96 | logger.Printf(logger.INFO, "[gns:%d:%d] Received request: %v\n", id, reqID, msg) |
97 | 97 | ||
98 | // handle message | 98 | // handle message |
99 | valueCtx := context.WithValue(ctx, service.CtxKey("label"), fmt.Sprintf(":%d:%d", id, reqID)) | 99 | valueCtx := context.WithValue(ctx, core.CtxKey("label"), fmt.Sprintf(":%d:%d", id, reqID)) |
100 | s.HandleMessage(valueCtx, nil, msg, mc) | 100 | s.HandleMessage(valueCtx, nil, msg, mc) |
101 | } | 101 | } |
102 | // close client connection | 102 | // close client connection |
@@ -136,7 +136,7 @@ func (s *Service) HandleMessage(ctx context.Context, sender *util.PeerID, msg me | |||
136 | logger.Printf(logger.DBG, "[gns%s] Lookup request finished.\n", label) | 136 | logger.Printf(logger.DBG, "[gns%s] Lookup request finished.\n", label) |
137 | }() | 137 | }() |
138 | 138 | ||
139 | kind := NewRRTypeList(enums.GNSType(m.Type)) | 139 | kind := NewRRTypeList(enums.GNSType(m.RType)) |
140 | recset, err := s.Resolve(ctx, label, m.Zone, kind, int(m.Options), 0) | 140 | recset, err := s.Resolve(ctx, label, m.Zone, kind, int(m.Options), 0) |
141 | if err != nil { | 141 | if err != nil { |
142 | logger.Printf(logger.ERROR, "[gns%s] Failed to lookup block: %s\n", label, err.Error()) | 142 | 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 | |||
159 | logger.Printf(logger.DBG, "[gns%s] Record #%d: %v\n", label, i, rec) | 159 | logger.Printf(logger.DBG, "[gns%s] Record #%d: %v\n", label, i, rec) |
160 | 160 | ||
161 | // is this the record type we are looking for? | 161 | // is this the record type we are looking for? |
162 | if rec.Type == m.Type || enums.GNSType(m.Type) == enums.GNS_TYPE_ANY { | 162 | if rec.RType == m.RType || enums.GNSType(m.RType) == enums.GNS_TYPE_ANY { |
163 | // add it to the response message | 163 | // add it to the response message |
164 | if err := resp.AddRecord(rec); err != nil { | 164 | if err := resp.AddRecord(rec); err != nil { |
165 | logger.Printf(logger.ERROR, "[gns%s] failed: %sv", label, err.Error()) | 165 | 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 | |||
173 | //---------------------------------------------------------- | 173 | //---------------------------------------------------------- |
174 | // UNKNOWN message type received | 174 | // UNKNOWN message type received |
175 | //---------------------------------------------------------- | 175 | //---------------------------------------------------------- |
176 | logger.Printf(logger.ERROR, "[gns%s] Unhandled message of type (%d)\n", label, msg.Header().MsgType) | 176 | logger.Printf(logger.ERROR, "[gns%s] Unhandled message of type (%s)\n", label, msg.Type()) |
177 | return false | 177 | return false |
178 | } | 178 | } |
179 | return true | 179 | return true |
@@ -238,7 +238,7 @@ func (s *Service) RevokeKey(ctx context.Context, rd *revocation.RevData) (succes | |||
238 | 238 | ||
239 | // LookupNamecache returns a cached lookup (if available) | 239 | // LookupNamecache returns a cached lookup (if available) |
240 | func (s *Service) LookupNamecache(ctx context.Context, query *blocks.GNSQuery) (block *blocks.GNSBlock, err error) { | 240 | func (s *Service) LookupNamecache(ctx context.Context, query *blocks.GNSQuery) (block *blocks.GNSBlock, err error) { |
241 | logger.Printf(logger.DBG, "[gns] LookupNamecache(%s)...\n", hex.EncodeToString(query.Key().Bits)) | 241 | logger.Printf(logger.DBG, "[gns] LookupNamecache(%s)...\n", hex.EncodeToString(query.Key().Data)) |
242 | 242 | ||
243 | // assemble Namecache request | 243 | // assemble Namecache request |
244 | req := message.NewNamecacheLookupMsg(query.Key()) | 244 | req := message.NewNamecacheLookupMsg(query.Key()) |
@@ -292,7 +292,7 @@ func (s *Service) LookupNamecache(ctx context.Context, query *blocks.GNSQuery) ( | |||
292 | break | 292 | break |
293 | } | 293 | } |
294 | default: | 294 | default: |
295 | logger.Printf(logger.ERROR, "[gns] Got invalid response type (%d)\n", m.Header().MsgType) | 295 | logger.Printf(logger.ERROR, "[gns] Got invalid response type (%s)\n", m.Type()) |
296 | err = ErrInvalidResponseType | 296 | err = ErrInvalidResponseType |
297 | } | 297 | } |
298 | return | 298 | return |
@@ -328,7 +328,7 @@ func (s *Service) StoreNamecache(ctx context.Context, query *blocks.GNSQuery, bl | |||
328 | } | 328 | } |
329 | return fmt.Errorf("failed with rc=%d", m.Result) | 329 | return fmt.Errorf("failed with rc=%d", m.Result) |
330 | default: | 330 | default: |
331 | logger.Printf(logger.ERROR, "[gns] Got invalid response type (%d)\n", m.Header().MsgType) | 331 | logger.Printf(logger.ERROR, "[gns] Got invalid response type (%s)\n", m.Type()) |
332 | err = ErrInvalidResponseType | 332 | err = ErrInvalidResponseType |
333 | } | 333 | } |
334 | return | 334 | return |
@@ -340,7 +340,7 @@ func (s *Service) StoreNamecache(ctx context.Context, query *blocks.GNSQuery, bl | |||
340 | 340 | ||
341 | // LookupDHT gets a GNS block from the DHT for the given query key. | 341 | // LookupDHT gets a GNS block from the DHT for the given query key. |
342 | func (s *Service) LookupDHT(ctx context.Context, query blocks.Query) (block blocks.Block, err error) { | 342 | func (s *Service) LookupDHT(ctx context.Context, query blocks.Query) (block blocks.Block, err error) { |
343 | logger.Printf(logger.DBG, "[gns] LookupDHT(%s)...\n", hex.EncodeToString(query.Key().Bits)) | 343 | logger.Printf(logger.DBG, "[gns] LookupDHT(%s)...\n", hex.EncodeToString(query.Key().Data)) |
344 | block = nil | 344 | block = nil |
345 | 345 | ||
346 | // client-connect to the DHT service | 346 | // client-connect to the DHT service |
@@ -375,7 +375,7 @@ func (s *Service) LookupDHT(ctx context.Context, query blocks.Query) (block bloc | |||
375 | reqGet := message.NewDHTClientGetMsg(query.Key()) | 375 | reqGet := message.NewDHTClientGetMsg(query.Key()) |
376 | reqGet.ID = uint64(util.NextID()) | 376 | reqGet.ID = uint64(util.NextID()) |
377 | reqGet.ReplLevel = uint32(enums.GNS_REPLICATION_LEVEL) | 377 | reqGet.ReplLevel = uint32(enums.GNS_REPLICATION_LEVEL) |
378 | reqGet.Type = uint32(enums.BLOCK_TYPE_GNS_NAMERECORD) | 378 | reqGet.BType = enums.BLOCK_TYPE_GNS_NAMERECORD |
379 | reqGet.Options = uint32(enums.DHT_RO_DEMULTIPLEX_EVERYWHERE) | 379 | reqGet.Options = uint32(enums.DHT_RO_DEMULTIPLEX_EVERYWHERE) |
380 | 380 | ||
381 | if err = interact(reqGet, true); err != nil { | 381 | if err = interact(reqGet, true); err != nil { |
@@ -413,7 +413,7 @@ func (s *Service) LookupDHT(ctx context.Context, query blocks.Query) (block bloc | |||
413 | break | 413 | break |
414 | } | 414 | } |
415 | // check if result is of requested type | 415 | // check if result is of requested type |
416 | if enums.BlockType(m.Type) != enums.BLOCK_TYPE_GNS_NAMERECORD { | 416 | if enums.BlockType(m.BType) != enums.BLOCK_TYPE_GNS_NAMERECORD { |
417 | logger.Println(logger.ERROR, "[gns] DHT response has wrong type") | 417 | logger.Println(logger.ERROR, "[gns] DHT response has wrong type") |
418 | break | 418 | break |
419 | } | 419 | } |
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) | |||
81 | // Heartbeat is a function prototype for periodic tasks | 81 | // Heartbeat is a function prototype for periodic tasks |
82 | type Heartbeat func(context.Context) | 82 | type Heartbeat func(context.Context) |
83 | 83 | ||
84 | // CtxKey is a value-context key | ||
85 | type CtxKey string | ||
86 | |||
87 | //---------------------------------------------------------------------- | 84 | //---------------------------------------------------------------------- |
88 | // Generic module implementation | 85 | // Generic module implementation |
89 | //---------------------------------------------------------------------- | 86 | //---------------------------------------------------------------------- |
@@ -121,7 +118,7 @@ func (m *ModuleImpl) Run( | |||
121 | select { | 118 | select { |
122 | // Handle events | 119 | // Handle events |
123 | case event := <-m.ch: | 120 | case event := <-m.ch: |
124 | hCtx := context.WithValue(ctx, CtxKey("label"), event.Label) | 121 | hCtx := context.WithValue(ctx, core.CtxKey("label"), event.Label) |
125 | hdlr(hCtx, event) | 122 | hdlr(hCtx, event) |
126 | 123 | ||
127 | // wait for terminate signal | 124 | // 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 ( | |||
23 | "gnunet/config" | 23 | "gnunet/config" |
24 | "gnunet/core" | 24 | "gnunet/core" |
25 | "gnunet/crypto" | 25 | "gnunet/crypto" |
26 | "gnunet/message" | 26 | "gnunet/enums" |
27 | "gnunet/service" | 27 | "gnunet/service" |
28 | "gnunet/service/store" | 28 | "gnunet/service/store" |
29 | "gnunet/util" | 29 | "gnunet/util" |
@@ -85,10 +85,10 @@ func NewModule(ctx context.Context, c *core.Core) (m *Module) { | |||
85 | // Filter returns the event filter for the service | 85 | // Filter returns the event filter for the service |
86 | func (m *Module) Filter() *core.EventFilter { | 86 | func (m *Module) Filter() *core.EventFilter { |
87 | f := core.NewEventFilter() | 87 | f := core.NewEventFilter() |
88 | f.AddMsgType(message.REVOCATION_QUERY) | 88 | f.AddMsgType(enums.MSG_REVOCATION_QUERY) |
89 | f.AddMsgType(message.REVOCATION_QUERY_RESPONSE) | 89 | f.AddMsgType(enums.MSG_REVOCATION_QUERY_RESPONSE) |
90 | f.AddMsgType(message.REVOCATION_REVOKE) | 90 | f.AddMsgType(enums.MSG_REVOCATION_REVOKE) |
91 | f.AddMsgType(message.REVOCATION_REVOKE_RESPONSE) | 91 | f.AddMsgType(enums.MSG_REVOCATION_REVOKE_RESPONSE) |
92 | return f | 92 | return f |
93 | } | 93 | } |
94 | 94 | ||
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 | |||
75 | logger.Printf(logger.INFO, "[revocation:%d:%d] Received request: %v\n", id, reqID, msg) | 75 | logger.Printf(logger.INFO, "[revocation:%d:%d] Received request: %v\n", id, reqID, msg) |
76 | 76 | ||
77 | // handle message | 77 | // handle message |
78 | valueCtx := context.WithValue(ctx, service.CtxKey("label"), fmt.Sprintf(":%d:%d", id, reqID)) | 78 | valueCtx := context.WithValue(ctx, core.CtxKey("label"), fmt.Sprintf(":%d:%d", id, reqID)) |
79 | s.HandleMessage(valueCtx, nil, msg, mc) | 79 | s.HandleMessage(valueCtx, nil, msg, mc) |
80 | } | 80 | } |
81 | // close client connection | 81 | // close client connection |
@@ -157,7 +157,7 @@ func (s *Service) HandleMessage(ctx context.Context, sender *util.PeerID, msg me | |||
157 | //---------------------------------------------------------- | 157 | //---------------------------------------------------------- |
158 | // UNKNOWN message type received | 158 | // UNKNOWN message type received |
159 | //---------------------------------------------------------- | 159 | //---------------------------------------------------------- |
160 | logger.Printf(logger.ERROR, "[revocation%s] Unhandled message of type (%d)\n", label, msg.Header().MsgType) | 160 | logger.Printf(logger.ERROR, "[revocation%s] Unhandled message of type (%s)\n", label, msg.Type()) |
161 | return false | 161 | return false |
162 | } | 162 | } |
163 | return true | 163 | 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) { | |||
166 | btype := query.Type() | 166 | btype := query.Type() |
167 | expire := entry.Blk.Expire() | 167 | expire := entry.Blk.Expire() |
168 | blkSize := len(entry.Blk.Bytes()) | 168 | blkSize := len(entry.Blk.Bytes()) |
169 | pl := 0 | ||
170 | if entry.Path != nil { | ||
171 | pl = int(entry.Path.NumList) | ||
172 | } | ||
173 | logger.Printf(logger.INFO, "[dht-store] storing %d bytes under key %s (path: %d)", | ||
174 | blkSize, query.Key().Short(), pl) | ||
169 | 175 | ||
170 | // write entry to file for storage | 176 | // write entry to file for storage |
171 | if err = s.writeEntry(query.Key().Bits, entry); err != nil { | 177 | if err = s.writeEntry(query.Key().Data, entry); err != nil { |
172 | return | 178 | return |
173 | } | 179 | } |
174 | // compile metadata | 180 | // compile metadata |
@@ -220,13 +226,13 @@ func (s *DHTStore) Get(label string, query blocks.Query, rf blocks.ResultFilter) | |||
220 | } | 226 | } |
221 | // read entry from storage | 227 | // read entry from storage |
222 | var entry *DHTEntry | 228 | var entry *DHTEntry |
223 | if entry, err = s.readEntry(md.key.Bits); err != nil { | 229 | if entry, err = s.readEntry(md); err != nil { |
224 | logger.Printf(logger.ERROR, "[%s] can't read DHT entry: %s", label, err) | 230 | logger.Printf(logger.ERROR, "[%s] can't read DHT entry: %s", label, err) |
225 | continue | 231 | continue |
226 | } | 232 | } |
227 | results = append(results, entry) | 233 | results = append(results, entry) |
228 | // mark the block as newly used | 234 | // mark the block as newly used |
229 | if err = s.meta.Used(md.key.Bits, md.btype); err != nil { | 235 | if err = s.meta.Used(md.key.Data, md.btype); err != nil { |
230 | logger.Printf(logger.ERROR, "[%s] can't flag DHT entry as used: %s", label, err) | 236 | logger.Printf(logger.ERROR, "[%s] can't flag DHT entry as used: %s", label, err) |
231 | continue | 237 | continue |
232 | } | 238 | } |
@@ -246,13 +252,13 @@ func (s *DHTStore) GetApprox(label string, query blocks.Query, rf blocks.ResultF | |||
246 | return | 252 | return |
247 | } | 253 | } |
248 | // check distance (max. 16 bucktes off) | 254 | // check distance (max. 16 bucktes off) |
249 | dist := util.Distance(md.key.Bits, query.Key().Bits) | 255 | dist := util.Distance(md.key.Data, query.Key().Data) |
250 | if (512 - dist.BitLen()) > 16 { | 256 | if (512 - dist.BitLen()) > 16 { |
251 | return | 257 | return |
252 | } | 258 | } |
253 | // read entry from storage | 259 | // read entry from storage |
254 | var entry *DHTEntry | 260 | var entry *DHTEntry |
255 | if entry, err = s.readEntry(md.key.Bits); err != nil { | 261 | if entry, err = s.readEntry(md); err != nil { |
256 | logger.Printf(logger.ERROR, "[%s] failed to retrieve block for %s", label, md.key.String()) | 262 | logger.Printf(logger.ERROR, "[%s] failed to retrieve block for %s", label, md.key.String()) |
257 | return | 263 | return |
258 | } | 264 | } |
@@ -278,9 +284,9 @@ type entryLayout struct { | |||
278 | } | 284 | } |
279 | 285 | ||
280 | // read entry from storage for given key | 286 | // read entry from storage for given key |
281 | func (s *DHTStore) readEntry(key []byte) (entry *DHTEntry, err error) { | 287 | func (s *DHTStore) readEntry(md *FileMetadata) (entry *DHTEntry, err error) { |
282 | // get path and filename from key | 288 | // get path and filename from key |
283 | folder, fname := s.expandPath(key) | 289 | folder, fname := s.expandPath(md.key.Data) |
284 | 290 | ||
285 | // open file for reading | 291 | // open file for reading |
286 | var file *os.File | 292 | var file *os.File |
@@ -300,7 +306,9 @@ func (s *DHTStore) readEntry(key []byte) (entry *DHTEntry, err error) { | |||
300 | } | 306 | } |
301 | // assemble entry | 307 | // assemble entry |
302 | entry = new(DHTEntry) | 308 | entry = new(DHTEntry) |
303 | entry.Blk = blocks.NewGenericBlock(val.Block) | 309 | if entry.Blk, err = blocks.NewBlock(md.btype, md.expires, val.Block); err != nil { |
310 | return | ||
311 | } | ||
304 | entry.Path, err = path.NewPathFromBytes(val.Path) | 312 | entry.Path, err = path.NewPathFromBytes(val.Path) |
305 | return | 313 | return |
306 | } | 314 | } |
@@ -366,12 +374,12 @@ func (s *DHTStore) dropFile(md *FileMetadata) (err error) { | |||
366 | // adjust total size | 374 | // adjust total size |
367 | s.totalSize -= md.size | 375 | s.totalSize -= md.size |
368 | // remove from database | 376 | // remove from database |
369 | if err = s.meta.Drop(md.key.Bits, md.btype); err != nil { | 377 | if err = s.meta.Drop(md.key.Data, md.btype); err != nil { |
370 | logger.Printf(logger.ERROR, "[store] can't remove metadata (%s,%d): %s", md.key, md.btype, err.Error()) | 378 | logger.Printf(logger.ERROR, "[store] can't remove metadata (%s,%d): %s", md.key, md.btype, err.Error()) |
371 | return | 379 | return |
372 | } | 380 | } |
373 | // remove from filesystem | 381 | // remove from filesystem |
374 | h := hex.EncodeToString(md.key.Bits) | 382 | h := hex.EncodeToString(md.key.Data) |
375 | path := fmt.Sprintf("%s/%s/%s/%s", s.path, h[:2], h[2:4], h[4:]) | 383 | path := fmt.Sprintf("%s/%s/%s/%s", s.path, h[:2], h[2:4], h[4:]) |
376 | if err = os.Remove(path); err != nil { | 384 | if err = os.Remove(path); err != nil { |
377 | logger.Printf(logger.ERROR, "[store] can't remove file %s: %s", path, err.Error()) | 385 | 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) { | |||
99 | func (db *FileMetaDB) Store(md *FileMetadata) (err error) { | 99 | func (db *FileMetaDB) Store(md *FileMetadata) (err error) { |
100 | sql := "replace into meta(qkey,btype,bhash,size,stored,expires,lastUsed,usedCount) values(?,?,?,?,?,?,?,?)" | 100 | sql := "replace into meta(qkey,btype,bhash,size,stored,expires,lastUsed,usedCount) values(?,?,?,?,?,?,?,?)" |
101 | _, err = db.conn.Exec(sql, | 101 | _, err = db.conn.Exec(sql, |
102 | md.key.Bits, md.btype, md.bhash.Bits, md.size, md.stored.Epoch(), | 102 | md.key.Data, md.btype, md.bhash.Data, md.size, md.stored.Epoch(), |
103 | md.expires.Epoch(), md.lastUsed.Epoch(), md.usedCount) | 103 | md.expires.Epoch(), md.lastUsed.Epoch(), md.usedCount) |
104 | return | 104 | return |
105 | } | 105 | } |
@@ -111,9 +111,9 @@ func (db *FileMetaDB) Get(query blocks.Query) (mds []*FileMetadata, err error) { | |||
111 | btype := query.Type() | 111 | btype := query.Type() |
112 | var rows *sql.Rows | 112 | var rows *sql.Rows |
113 | if btype == enums.BLOCK_TYPE_ANY { | 113 | if btype == enums.BLOCK_TYPE_ANY { |
114 | rows, err = db.conn.Query(stmt, query.Key().Bits) | 114 | rows, err = db.conn.Query(stmt, query.Key().Data) |
115 | } else { | 115 | } else { |
116 | rows, err = db.conn.Query(stmt+" and btype=?", query.Key().Bits, btype) | 116 | rows, err = db.conn.Query(stmt+" and btype=?", query.Key().Data, btype) |
117 | } | 117 | } |
118 | if err != nil { | 118 | if err != nil { |
119 | return | 119 | return |
@@ -124,7 +124,7 @@ func (db *FileMetaDB) Get(query blocks.Query) (mds []*FileMetadata, err error) { | |||
124 | md.key = query.Key() | 124 | md.key = query.Key() |
125 | md.btype = btype | 125 | md.btype = btype |
126 | var st, exp, lu uint64 | 126 | var st, exp, lu uint64 |
127 | if err = rows.Scan(&md.size, &md.bhash.Bits, &st, &exp, &lu, &md.usedCount); err != nil { | 127 | if err = rows.Scan(&md.size, &md.bhash.Data, &st, &exp, &lu, &md.usedCount); err != nil { |
128 | if err == sql.ErrNoRows { | 128 | if err == sql.ErrNoRows { |
129 | md = nil | 129 | md = nil |
130 | err = nil | 130 | err = nil |
@@ -194,7 +194,7 @@ func (db *FileMetaDB) Traverse(f func(*FileMetadata)) error { | |||
194 | md := NewFileMetadata() | 194 | md := NewFileMetadata() |
195 | for rows.Next() { | 195 | for rows.Next() { |
196 | var st, exp, lu uint64 | 196 | var st, exp, lu uint64 |
197 | err = rows.Scan(&md.key.Bits, &md.btype, &md.bhash.Bits, &md.size, &st, &exp, &lu, &md.usedCount) | 197 | err = rows.Scan(&md.key.Data, &md.btype, &md.bhash.Data, &md.size, &st, &exp, &lu, &md.usedCount) |
198 | if err != nil { | 198 | if err != nil { |
199 | return err | 199 | return err |
200 | } | 200 | } |
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) { | |||
66 | rf := blocks.NewGenericResultFilter() | 66 | rf := blocks.NewGenericResultFilter() |
67 | 67 | ||
68 | // First round: save blocks | 68 | // First round: save blocks |
69 | btype := enums.BLOCK_TYPE_TEST | ||
70 | expire := util.AbsoluteTimeNever() | ||
69 | for i := 0; i < fsNumBlocks; i++ { | 71 | for i := 0; i < fsNumBlocks; i++ { |
70 | // generate random block | 72 | // generate random block |
71 | size := 1024 + rand.Intn(62000) //nolint:gosec // good enough for testing | 73 | size := 1024 + rand.Intn(62000) //nolint:gosec // good enough for testing |
@@ -73,10 +75,13 @@ func TestDHTFilesStore(t *testing.T) { | |||
73 | if _, err = rand.Read(buf); err != nil { //nolint:gosec // good enough for testing | 75 | if _, err = rand.Read(buf); err != nil { //nolint:gosec // good enough for testing |
74 | t.Fatal(err) | 76 | t.Fatal(err) |
75 | } | 77 | } |
76 | blk := blocks.NewGenericBlock(buf) | 78 | var blk blocks.Block |
79 | if blk, err = blocks.NewBlock(btype, expire, buf); err != nil { | ||
80 | t.Fatal(err) | ||
81 | } | ||
77 | // generate associated key | 82 | // generate associated key |
78 | k := crypto.Hash(buf) | 83 | k := crypto.Hash(buf) |
79 | key := blocks.NewGenericQuery(k, enums.BLOCK_TYPE_ANY, 0) | 84 | key := blocks.NewGenericQuery(k, enums.BLOCK_TYPE_TEST, 0) |
80 | 85 | ||
81 | // store entry | 86 | // store entry |
82 | val := &DHTEntry{ | 87 | val := &DHTEntry{ |
@@ -105,9 +110,9 @@ func TestDHTFilesStore(t *testing.T) { | |||
105 | k := crypto.Hash(buf) | 110 | k := crypto.Hash(buf) |
106 | 111 | ||
107 | // do the keys match? | 112 | // do the keys match? |
108 | if !k.Equals(key.Key()) { | 113 | if !k.Equal(key.Key()) { |
109 | t.Log(hex.EncodeToString(k.Bits)) | 114 | t.Log(hex.EncodeToString(k.Data)) |
110 | t.Log(hex.EncodeToString(key.Key().Bits)) | 115 | t.Log(hex.EncodeToString(key.Key().Data)) |
111 | t.Fatal("key/value mismatch") | 116 | t.Fatal("key/value mismatch") |
112 | } | 117 | } |
113 | } | 118 | } |
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) | |||
41 | if buf, err = data.Marshal(msg); err != nil { | 41 | if buf, err = data.Marshal(msg); err != nil { |
42 | return | 42 | return |
43 | } | 43 | } |
44 | /* | ||
45 | // debug for outgoing messages | ||
46 | if msg.Type() == enums.MSG_DHT_P2P_HELLO { | ||
47 | logger.Printf(logger.DBG, "[rw_msg] msg=%s", hex.EncodeToString(buf)) | ||
48 | logger.Printf(logger.DBG, "[rw_msg] msg=%s", util.Dump(msg, "json")) | ||
49 | } | ||
50 | */ | ||
44 | // check message header size and packet size | 51 | // check message header size and packet size |
45 | mh, err := message.GetMsgHeader(buf) | 52 | mh, err := message.GetMsgHeader(buf) |
46 | if err != nil { | 53 | if err != nil { |
@@ -92,7 +99,7 @@ func ReadMessage(ctx context.Context, rdr io.ReadCloser, buf []byte) (msg messag | |||
92 | if err = get(0, 4); err != nil { | 99 | if err = get(0, 4); err != nil { |
93 | return | 100 | return |
94 | } | 101 | } |
95 | var mh *message.Header | 102 | var mh *message.MsgHeader |
96 | if mh, err = message.GetMsgHeader(buf[:4]); err != nil { | 103 | if mh, err = message.GetMsgHeader(buf[:4]); err != nil { |
97 | return | 104 | return |
98 | } | 105 | } |
@@ -108,6 +115,13 @@ func ReadMessage(ctx context.Context, rdr io.ReadCloser, buf []byte) (msg messag | |||
108 | return | 115 | return |
109 | } | 116 | } |
110 | err = data.Unmarshal(msg, buf[:mh.MsgSize]) | 117 | err = data.Unmarshal(msg, buf[:mh.MsgSize]) |
118 | /* | ||
119 | // debug for incoming messages | ||
120 | if mh.MsgType == enums.MSG_DHT_P2P_RESULT { | ||
121 | logger.Printf(logger.DBG, "[rw_msg] msg=%s", hex.EncodeToString(buf[:mh.MsgSize])) | ||
122 | logger.Printf(logger.DBG, "[rw_msg] msg=%s", util.Dump(msg, "json")) | ||
123 | } | ||
124 | */ | ||
111 | return | 125 | return |
112 | } | 126 | } |
113 | 127 | ||
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 ( | |||
29 | type Address struct { | 29 | type Address struct { |
30 | Netw string // network protocol | 30 | Netw string // network protocol |
31 | Options uint32 // address options | 31 | Options uint32 // address options |
32 | Expires AbsoluteTime // expiration date for address | 32 | Expire AbsoluteTime // expiration date for address |
33 | Address []byte // address data (protocol-dependent) | 33 | Address []byte // address data (protocol-dependent) |
34 | } | 34 | } |
35 | 35 | ||
@@ -39,7 +39,7 @@ func NewAddress(transport string, addr string) *Address { | |||
39 | Netw: transport, | 39 | Netw: transport, |
40 | Options: 0, | 40 | Options: 0, |
41 | Address: Clone([]byte(addr)), | 41 | Address: Clone([]byte(addr)), |
42 | Expires: AbsoluteTimeNever(), | 42 | Expire: AbsoluteTimeNever(), |
43 | } | 43 | } |
44 | } | 44 | } |
45 | 45 | ||
@@ -50,7 +50,7 @@ func NewAddressWrap(addr net.Addr) *Address { | |||
50 | Netw: addr.Network(), | 50 | Netw: addr.Network(), |
51 | Options: 0, | 51 | Options: 0, |
52 | Address: []byte(addr.String()), | 52 | Address: []byte(addr.String()), |
53 | Expires: AbsoluteTimeNever(), | 53 | Expire: AbsoluteTimeNever(), |
54 | } | 54 | } |
55 | } | 55 | } |
56 | 56 | ||
@@ -67,8 +67,8 @@ func ParseAddress(s string) (addr *Address, err error) { | |||
67 | return | 67 | return |
68 | } | 68 | } |
69 | 69 | ||
70 | // Equals return true if two addresses match. | 70 | // Equal return true if two addresses match. |
71 | func (a *Address) Equals(b *Address) bool { | 71 | func (a *Address) Equal(b *Address) bool { |
72 | return a.Netw == b.Netw && | 72 | return a.Netw == b.Netw && |
73 | a.Options == b.Options && | 73 | a.Options == b.Options && |
74 | bytes.Equal(a.Address, b.Address) | 74 | bytes.Equal(a.Address, b.Address) |
@@ -115,7 +115,7 @@ func NewPeerAddrList() *PeerAddrList { | |||
115 | func (a *PeerAddrList) Add(peer *PeerID, addr *Address) (mode int) { | 115 | func (a *PeerAddrList) Add(peer *PeerID, addr *Address) (mode int) { |
116 | // check for expired address. | 116 | // check for expired address. |
117 | mode = 0 | 117 | mode = 0 |
118 | if !addr.Expires.Expired() { | 118 | if !addr.Expire.Expired() { |
119 | // run add operation | 119 | // run add operation |
120 | _ = a.list.Process(func(pid int) error { | 120 | _ = a.list.Process(func(pid int) error { |
121 | id := peer.String() | 121 | id := peer.String() |
@@ -125,7 +125,7 @@ func (a *PeerAddrList) Add(peer *PeerID, addr *Address) (mode int) { | |||
125 | mode = 1 | 125 | mode = 1 |
126 | } else { | 126 | } else { |
127 | for _, a := range list { | 127 | for _, a := range list { |
128 | if a.Equals(addr) { | 128 | if a.Equal(addr) { |
129 | return nil | 129 | return nil |
130 | } | 130 | } |
131 | } | 131 | } |
@@ -146,7 +146,7 @@ func (a *PeerAddrList) Get(peer *PeerID, transport string) (res []*Address) { | |||
146 | if ok { | 146 | if ok { |
147 | for _, addr := range list { | 147 | for _, addr := range list { |
148 | // check for expired address. | 148 | // check for expired address. |
149 | if addr.Expires.Expired() { | 149 | if addr.Expire.Expired() { |
150 | // skip expired | 150 | // skip expired |
151 | continue | 151 | continue |
152 | } | 152 | } |
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 { | |||
43 | return r | 43 | return r |
44 | } | 44 | } |
45 | 45 | ||
46 | // Equals returns true if two arrays match. | 46 | // Equal returns true if two arrays match. |
47 | func Equals[T []E, E comparable](a, b T) bool { | 47 | func Equal[T []E, E comparable](a, b T) bool { |
48 | if len(a) != len(b) { | 48 | if len(a) != len(b) { |
49 | return false | 49 | return false |
50 | } | 50 | } |
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 { | |||
96 | return s | 96 | return s |
97 | } | 97 | } |
98 | 98 | ||
99 | // Shorten string for output | ||
100 | func Shorten(s string, n int) string { | ||
101 | l := len(s) | ||
102 | p := n - 3 | ||
103 | if p < 3 { | ||
104 | return s | ||
105 | } | ||
106 | k := p % 2 | ||
107 | p /= 2 | ||
108 | return s[:p+k] + "..." + s[l-p:] | ||
109 | } | ||
110 | |||
99 | //---------------------------------------------------------------------- | 111 | //---------------------------------------------------------------------- |
100 | // Dump instance | 112 | // Dump instance |
101 | func Dump(obj any, format string) string { | 113 | 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) { | |||
80 | } | 80 | } |
81 | } | 81 | } |
82 | 82 | ||
83 | // Equals returns true if two peer IDs match. | 83 | // Equal returns true if two peer IDs match. |
84 | func (p *PeerID) Equals(q *PeerID) bool { | 84 | func (p *PeerID) Equal(q *PeerID) bool { |
85 | if q == nil { | ||
86 | return p == nil | ||
87 | } | ||
85 | return bytes.Equal(p.Data, q.Data) | 88 | return bytes.Equal(p.Data, q.Data) |
86 | } | 89 | } |
87 | 90 | ||
@@ -90,6 +93,11 @@ func (p *PeerID) String() string { | |||
90 | return EncodeBinaryToString(p.Data) | 93 | return EncodeBinaryToString(p.Data) |
91 | } | 94 | } |
92 | 95 | ||
96 | // SHort returns a shortened peer id for display | ||
97 | func (p *PeerID) Short() string { | ||
98 | return p.String()[:8] | ||
99 | } | ||
100 | |||
93 | // Bytes returns the binary representation of a peer identifier. | 101 | // Bytes returns the binary representation of a peer identifier. |
94 | func (p *PeerID) Bytes() []byte { | 102 | func (p *PeerID) Bytes() []byte { |
95 | return Clone(p.Data) | 103 | 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 { | |||
81 | } | 81 | } |
82 | } | 82 | } |
83 | 83 | ||
84 | // Add a relative time to an absolute time yielding a new absolute time. | ||
85 | func (t AbsoluteTime) AddRelative(d RelativeTime) AbsoluteTime { | ||
86 | return AbsoluteTime{ | ||
87 | Val: t.Val + d.Val, | ||
88 | } | ||
89 | } | ||
90 | |||
84 | // Elapsed time since 't'. Return 0 if 't' is in the future. | 91 | // Elapsed time since 't'. Return 0 if 't' is in the future. |
85 | func (t AbsoluteTime) Elapsed() RelativeTime { | 92 | func (t AbsoluteTime) Elapsed() RelativeTime { |
86 | dt, elapsed := t.Diff(AbsoluteTimeNow()) | 93 | dt, elapsed := t.Diff(AbsoluteTimeNow()) |
@@ -107,11 +114,7 @@ func (t AbsoluteTime) Diff(t2 AbsoluteTime) (dt RelativeTime, elapsed bool) { | |||
107 | 114 | ||
108 | // Expired returns true if the timestamp is in the past. | 115 | // Expired returns true if the timestamp is in the past. |
109 | func (t AbsoluteTime) Expired() bool { | 116 | func (t AbsoluteTime) Expired() bool { |
110 | // check for "never" | 117 | return t.Compare(AbsoluteTimeNow()) < 0 |
111 | if t.Val == math.MaxUint64 { | ||
112 | return false | ||
113 | } | ||
114 | return t.Val < uint64(time.Now().Unix()) | ||
115 | } | 118 | } |
116 | 119 | ||
117 | // Compare two times (-1 = (t < t2), 0 = (t == t2), 1 = (t > t2) | 120 | // Compare two times (-1 = (t < t2), 0 = (t == t2), 1 = (t > t2) |