Tweaks to Dendrite Yggdrasil demo setup
parent
99ea1f9b48
commit
b21fad92e5
|
@ -55,7 +55,7 @@ func (m *DendriteMonolith) DisconnectMulticastPeers() {
|
||||||
m.YggdrasilNode.DisconnectMulticastPeers()
|
m.YggdrasilNode.DisconnectMulticastPeers()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *DendriteMonolith) Start(staticPeer string, enableMulticast bool) {
|
func (m *DendriteMonolith) Start() {
|
||||||
logger := logrus.Logger{
|
logger := logrus.Logger{
|
||||||
Out: BindLogger{},
|
Out: BindLogger{},
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ func (m *DendriteMonolith) Start(staticPeer string, enableMulticast bool) {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ygg, err := yggconn.Setup("dendrite", staticPeer, m.StorageDirectory, enableMulticast)
|
ygg, err := yggconn.Setup("dendrite", m.StorageDirectory)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,10 +54,11 @@ func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
internal.SetupPprof()
|
internal.SetupPprof()
|
||||||
|
|
||||||
ygg, err := yggconn.Setup(*instanceName, *instancePeer, ".", true)
|
ygg, err := yggconn.Setup(*instanceName, ".")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
ygg.SetMulticastEnabled(true)
|
||||||
|
|
||||||
cfg := &config.Dendrite{}
|
cfg := &config.Dendrite{}
|
||||||
cfg.SetDefaults()
|
cfg.SetDefaults()
|
||||||
|
|
|
@ -80,7 +80,7 @@ func (n *Node) DialerContext(ctx context.Context, network, address string) (net.
|
||||||
}
|
}
|
||||||
|
|
||||||
// nolint:gocyclo
|
// nolint:gocyclo
|
||||||
func Setup(instanceName, instancePeer, storageDirectory string, enableMulticast bool) (*Node, error) {
|
func Setup(instanceName, storageDirectory string) (*Node, error) {
|
||||||
n := &Node{
|
n := &Node{
|
||||||
core: &yggdrasil.Core{},
|
core: &yggdrasil.Core{},
|
||||||
config: yggdrasilconfig.GenerateConfig(),
|
config: yggdrasilconfig.GenerateConfig(),
|
||||||
|
@ -102,17 +102,9 @@ func Setup(instanceName, instancePeer, storageDirectory string, enableMulticast
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if instancePeer != "" {
|
n.config.Peers = []string{}
|
||||||
n.config.Peers = []string{instancePeer}
|
|
||||||
} else {
|
|
||||||
n.config.Peers = []string{}
|
|
||||||
}
|
|
||||||
n.config.AdminListen = "none"
|
n.config.AdminListen = "none"
|
||||||
if enableMulticast {
|
n.config.MulticastInterfaces = []string{}
|
||||||
n.config.MulticastInterfaces = []string{".*"}
|
|
||||||
} else {
|
|
||||||
n.config.MulticastInterfaces = []string{}
|
|
||||||
}
|
|
||||||
n.config.EncryptionPrivateKey = hex.EncodeToString(n.EncryptionPrivateKey())
|
n.config.EncryptionPrivateKey = hex.EncodeToString(n.EncryptionPrivateKey())
|
||||||
n.config.EncryptionPublicKey = hex.EncodeToString(n.EncryptionPublicKey())
|
n.config.EncryptionPublicKey = hex.EncodeToString(n.EncryptionPublicKey())
|
||||||
|
|
||||||
|
@ -197,11 +189,9 @@ func (n *Node) PeerCount() int {
|
||||||
|
|
||||||
func (n *Node) KnownNodes() []gomatrixserverlib.ServerName {
|
func (n *Node) KnownNodes() []gomatrixserverlib.ServerName {
|
||||||
nodemap := map[string]struct{}{}
|
nodemap := map[string]struct{}{}
|
||||||
/*
|
for _, peer := range n.core.GetSwitchPeers() {
|
||||||
for _, peer := range n.core.GetSwitchPeers() {
|
nodemap[hex.EncodeToString(peer.SigningKey[:])] = struct{}{}
|
||||||
nodemap[hex.EncodeToString(peer.SigningKey[:])] = struct{}{}
|
}
|
||||||
}
|
|
||||||
*/
|
|
||||||
n.sessions.Range(func(_, v interface{}) bool {
|
n.sessions.Range(func(_, v interface{}) bool {
|
||||||
session, ok := v.(quic.Session)
|
session, ok := v.(quic.Session)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -262,7 +252,11 @@ func (n *Node) SetStaticPeer(uri string) error {
|
||||||
if uri != "" {
|
if uri != "" {
|
||||||
n.log.Infoln("Adding static peer", uri)
|
n.log.Infoln("Adding static peer", uri)
|
||||||
if err := n.core.AddPeer(uri, ""); err != nil {
|
if err := n.core.AddPeer(uri, ""); err != nil {
|
||||||
n.log.Infoln("Adding static peer failed:", err)
|
n.log.Warnln("Adding static peer failed:", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := n.core.CallPeer(uri, ""); err != nil {
|
||||||
|
n.log.Warnln("Calling static peer failed:", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -36,7 +36,7 @@ require (
|
||||||
github.com/uber-go/atomic v1.3.0 // indirect
|
github.com/uber-go/atomic v1.3.0 // indirect
|
||||||
github.com/uber/jaeger-client-go v2.15.0+incompatible
|
github.com/uber/jaeger-client-go v2.15.0+incompatible
|
||||||
github.com/uber/jaeger-lib v1.5.0
|
github.com/uber/jaeger-lib v1.5.0
|
||||||
github.com/yggdrasil-network/yggdrasil-go v0.3.15-0.20200706132141-82b2af2963bf
|
github.com/yggdrasil-network/yggdrasil-go v0.3.15-0.20200707124509-16343a00055c
|
||||||
go.uber.org/atomic v1.4.0
|
go.uber.org/atomic v1.4.0
|
||||||
golang.org/x/crypto v0.0.0-20200423211502-4bdfaf469ed5
|
golang.org/x/crypto v0.0.0-20200423211502-4bdfaf469ed5
|
||||||
gopkg.in/h2non/bimg.v1 v1.0.18
|
gopkg.in/h2non/bimg.v1 v1.0.18
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -652,8 +652,8 @@ github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhe
|
||||||
github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y=
|
github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y=
|
||||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
||||||
github.com/yggdrasil-network/yggdrasil-extras v0.0.0-20200525205615-6c8a4a2e8855/go.mod h1:xQdsh08Io6nV4WRnOVTe6gI8/2iTvfLDQ0CYa5aMt+I=
|
github.com/yggdrasil-network/yggdrasil-extras v0.0.0-20200525205615-6c8a4a2e8855/go.mod h1:xQdsh08Io6nV4WRnOVTe6gI8/2iTvfLDQ0CYa5aMt+I=
|
||||||
github.com/yggdrasil-network/yggdrasil-go v0.3.15-0.20200706132141-82b2af2963bf h1:80RhF740jE7Rry2tg0UGnye95vBTZ/G6RNCBM7oiivE=
|
github.com/yggdrasil-network/yggdrasil-go v0.3.15-0.20200707124509-16343a00055c h1:tK1FySfDA5xVT5sAK/3XjUCE9LEoandmVnrg4Hj0fXk=
|
||||||
github.com/yggdrasil-network/yggdrasil-go v0.3.15-0.20200706132141-82b2af2963bf/go.mod h1:d+Nz6SPeG6kmeSPFL0cvfWfgwEql75fUnZiAONgvyBE=
|
github.com/yggdrasil-network/yggdrasil-go v0.3.15-0.20200707124509-16343a00055c/go.mod h1:d+Nz6SPeG6kmeSPFL0cvfWfgwEql75fUnZiAONgvyBE=
|
||||||
go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA=
|
go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA=
|
||||||
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
||||||
go.opencensus.io v0.22.1/go.mod h1:Ap50jQcDJrx6rB6VgeeFPtuPIf3wMRvRfrfYDO6+BmA=
|
go.opencensus.io v0.22.1/go.mod h1:Ap50jQcDJrx6rB6VgeeFPtuPIf3wMRvRfrfYDO6+BmA=
|
||||||
|
|
Loading…
Reference in New Issue