instantiate autonat service
License: MIT Signed-off-by: vyzo <vyzo@hackzen.org>
vyzo committed
Nov 28, 2018 at 15:09 UTC
19ab1248ebdf0b25f4c80849a37434d3be1e0524
2 files changed
+18
-3
core/core.go
+12
-2
@@ -64,6 +64,7 @@ import (
64
resolver "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path/resolver"
65
connmgr "gx/ipfs/QmZNGvvTqtVtGzVxkhRCu5nuwbytdRdtHtJbWLGxeMYAkt/go-libp2p-connmgr"
66
mplex "gx/ipfs/QmZsejKNkeFSQe5TcmYXJ8iq6qPL1FpsP4eAA8j7RfE7xg/go-smux-multiplex"
67
+ autonat "gx/ipfs/Qma7kuzdE11SExUDhxToEtHfmp93S6Xz8G4Bwj7WezXy3y/go-libp2p-autonat-svc"
68
pubsub "gx/ipfs/QmaTfHazBrintpyALv8MzmCvGyGg3XWY7vDrsVfGVnpd1j/go-libp2p-pubsub"
69
metrics "gx/ipfs/QmbYN6UmTJn5UUQdi5CTsU86TXVBSrTcRk5UmyA36Qx2J6/go-libp2p-metrics"
70
ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format"
@@ -134,6 +135,7 @@ type IpfsNode struct {
135
Reprovider *rp.Reprovider // the value reprovider system
136
IpnsRepub *ipnsrp.Republisher
137
138
+ AutoNAT *autonat.AutoNATService
139
PubSub *pubsub.PubSub
140
PSRouter *psrouter.PubsubValueStore
141
DHT *dht.IpfsDHT
@@ -471,12 +473,20 @@ func (n *IpfsNode) HandlePeerFound(p pstore.PeerInfo) {
473
// startOnlineServicesWithHost is the set of services which need to be
474
// initialized with the host and _before_ we start listening.
475
func (n *IpfsNode) startOnlineServicesWithHost(ctx context.Context, host p2phost.Host, routingOption RoutingOption, enablePubsub bool, enableIpnsps bool) error {
474
- if enablePubsub || enableIpnsps {
475
- cfg, err := n.Repo.Config()
476
+ cfg, err := n.Repo.Config()
477
+ if err != nil {
478
+ return err
479
+ }
480
+
481
+ if cfg.Swarm.EnableAutoNATService {
482
+ svc, err := autonat.NewAutoNATService(ctx, host)
483
if err != nil {
484
return err
485
}
486
+ n.AutoNAT = svc
487
+ }
488
489
+ if enablePubsub || enableIpnsps {
490
var service *pubsub.PubSub
491
492
var pubsubOptions []pubsub.Option
package.json
+6
-1
@@ -598,6 +598,12 @@
598
"hash": "QmWGnBLJhzZ3xV5YQuS6CqczN143YmGAFQTMAdJ31msoK5",
599
"name": "go-libp2p-http",
600
"version": "1.1.8"
601
+ },
602
+ {
603
+ "author": "vyzo",
604
+ "hash": "Qma7kuzdE11SExUDhxToEtHfmp93S6Xz8G4Bwj7WezXy3y",
605
+ "name": "go-libp2p-autonat-svc",
606
+ "version": "1.0.2"
607
}
608
],
609
"gxVersion": "0.10.0",
@@ -606,4 +612,3 @@
612
"name": "go-ipfs",
613
"version": "0.4.18"
614
}
609
-