|
@@ -22,6 +22,7 @@ import (
|
|
|
|
|
|
"github.com/ipfs/go-log"
|
|
|
"github.com/libp2p/go-libp2p"
|
|
|
+ dht "github.com/libp2p/go-libp2p-kad-dht"
|
|
|
"github.com/mudler/edgevpn/pkg/blockchain"
|
|
|
discovery "github.com/mudler/edgevpn/pkg/discovery"
|
|
|
"github.com/mudler/edgevpn/pkg/protocol"
|
|
@@ -227,15 +228,15 @@ func (y YAMLConnectionConfig) YAML() string {
|
|
|
return string(bytesData)
|
|
|
}
|
|
|
|
|
|
-func (y YAMLConnectionConfig) copy(mdns, dht bool, cfg *Config) {
|
|
|
- d := &discovery.DHT{
|
|
|
- RefreshDiscoveryTime: cfg.DiscoveryInterval,
|
|
|
- OTPInterval: y.OTP.DHT.Interval,
|
|
|
- OTPKey: y.OTP.DHT.Key,
|
|
|
- KeyLength: y.OTP.DHT.Length,
|
|
|
- RendezvousString: y.Rendezvous,
|
|
|
- BootstrapPeers: cfg.DiscoveryBootstrapPeers,
|
|
|
- }
|
|
|
+func (y YAMLConnectionConfig) copy(mdns, dht bool, cfg *Config, opts ...dht.Option) {
|
|
|
+ d := discovery.NewDHT(opts...)
|
|
|
+ d.RefreshDiscoveryTime = cfg.DiscoveryInterval
|
|
|
+ d.OTPInterval = y.OTP.DHT.Interval
|
|
|
+ d.OTPKey = y.OTP.DHT.Key
|
|
|
+ d.KeyLength = y.OTP.DHT.Length
|
|
|
+ d.RendezvousString = y.Rendezvous
|
|
|
+ d.BootstrapPeers = cfg.DiscoveryBootstrapPeers
|
|
|
+
|
|
|
m := &discovery.MDNS{DiscoveryServiceTag: y.MDNS}
|
|
|
cfg.ExchangeKey = y.OTP.Crypto.Key
|
|
|
cfg.RoomName = y.RoomName
|
|
@@ -283,7 +284,7 @@ func GenerateNewConnectionData(i ...int) *YAMLConnectionConfig {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func FromYaml(enablemDNS, enableDHT bool, path string) func(cfg *Config) error {
|
|
|
+func FromYaml(enablemDNS, enableDHT bool, path string, d ...dht.Option) func(cfg *Config) error {
|
|
|
return func(cfg *Config) error {
|
|
|
if len(path) == 0 {
|
|
|
return nil
|
|
@@ -299,12 +300,12 @@ func FromYaml(enablemDNS, enableDHT bool, path string) func(cfg *Config) error {
|
|
|
return errors.Wrap(err, "parsing yaml")
|
|
|
}
|
|
|
|
|
|
- t.copy(enablemDNS, enableDHT, cfg)
|
|
|
+ t.copy(enablemDNS, enableDHT, cfg, d...)
|
|
|
return nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func FromBase64(enablemDNS, enableDHT bool, bb string) func(cfg *Config) error {
|
|
|
+func FromBase64(enablemDNS, enableDHT bool, bb string, d ...dht.Option) func(cfg *Config) error {
|
|
|
return func(cfg *Config) error {
|
|
|
if len(bb) == 0 {
|
|
|
return nil
|
|
@@ -318,7 +319,7 @@ func FromBase64(enablemDNS, enableDHT bool, bb string) func(cfg *Config) error {
|
|
|
if err := yaml.Unmarshal(configDec, &t); err != nil {
|
|
|
return errors.Wrap(err, "parsing yaml")
|
|
|
}
|
|
|
- t.copy(enablemDNS, enableDHT, cfg)
|
|
|
+ t.copy(enablemDNS, enableDHT, cfg, d...)
|
|
|
return nil
|
|
|
}
|
|
|
}
|