diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2020-07-16 13:52:08 +0100 |
---|---|---|
committer | Neil Alexander <neilalexander@users.noreply.github.com> | 2020-07-16 13:52:08 +0100 |
commit | e5208c2ec9b5e1878c3f9860c98de29a9d95ca18 (patch) | |
tree | 1661c2f912202d2aea4130c2ac55e77d47ecbbcb /build | |
parent | f5e7e7513ca0ecddafc967e3b20f35cb1201a151 (diff) |
Yggdrasil demo updates ("Bare QUIC")
Squashed commit of the following:
commit 86c2388e13ffdbabdd50cea205652dccc40e1860
Merge: b0a3ee6c f5e7e751
Author: Neil Alexander <neilalexander@users.noreply.github.com>
Date: Thu Jul 16 13:47:10 2020 +0100
Merge branch 'master' into neilalexander/yggbarequic
commit b0a3ee6c5c063962384bb91c59ec753ddc8cfe5f
Author: Neil Alexander <neilalexander@users.noreply.github.com>
Date: Thu Jul 16 13:42:22 2020 +0100
Add support for broadcasting wake-up EDUs to known hosts
commit 8a5c2020b3a4b705b5d5686a9e71990a49e6d471
Author: Neil Alexander <neilalexander@users.noreply.github.com>
Date: Thu Jul 16 13:42:10 2020 +0100
Bare QUIC demo working
commit d3939b3d6568cf4262c0391486a5203873b68bfc
Author: Neil Alexander <neilalexander@users.noreply.github.com>
Date: Wed Jul 15 11:42:43 2020 +0100
Support bare Yggdrasil sessions with encrypted QUIC
Diffstat (limited to 'build')
-rw-r--r-- | build/gobind/monolith.go | 67 |
1 files changed, 16 insertions, 51 deletions
diff --git a/build/gobind/monolith.go b/build/gobind/monolith.go index bc638d00..7b0385bc 100644 --- a/build/gobind/monolith.go +++ b/build/gobind/monolith.go @@ -3,7 +3,6 @@ package gobind import ( "context" "crypto/tls" - "encoding/hex" "fmt" "net" "net/http" @@ -25,7 +24,6 @@ import ( "github.com/matrix-org/dendrite/userapi" "github.com/matrix-org/gomatrixserverlib" "github.com/sirupsen/logrus" - "github.com/yggdrasil-network/yggdrasil-go/src/crypto" "go.uber.org/atomic" ) @@ -169,33 +167,6 @@ func (m *DendriteMonolith) Start() { base.UseHTTPAPIs, ) - ygg.NewSession = func(serverName gomatrixserverlib.ServerName) { - logrus.Infof("Found new session %q", serverName) - time.Sleep(time.Second * 3) - req := &api.PerformServersAliveRequest{ - Servers: []gomatrixserverlib.ServerName{serverName}, - } - res := &api.PerformServersAliveResponse{} - if err := fsAPI.PerformServersAlive(context.TODO(), req, res); err != nil { - logrus.WithError(err).Warn("Failed to notify server alive due to new session") - } - } - - ygg.NotifyLinkNew(func(_ crypto.BoxPubKey, sigPubKey crypto.SigPubKey, linkType, remote string) { - serverName := hex.EncodeToString(sigPubKey[:]) - logrus.Infof("Found new peer %q", serverName) - time.Sleep(time.Second * 3) - req := &api.PerformServersAliveRequest{ - Servers: []gomatrixserverlib.ServerName{ - gomatrixserverlib.ServerName(serverName), - }, - } - res := &api.PerformServersAliveResponse{} - if err := fsAPI.PerformServersAlive(context.TODO(), req, res); err != nil { - logrus.WithError(err).Warn("Failed to notify server alive due to new session") - } - }) - // Build both ends of a HTTP multiplex. m.httpServer = &http.Server{ Addr: ":0", @@ -209,28 +180,22 @@ func (m *DendriteMonolith) Start() { Handler: base.BaseMux, } - m.Resume() -} - -func (m *DendriteMonolith) Resume() { - logrus.Info("Resuming monolith") - if listener, err := net.Listen("tcp", "localhost:65432"); err == nil { - m.listener = listener - } - if m.yggListening.CAS(false, true) { - go func() { - m.logger.Info("Listening on ", m.YggdrasilNode.DerivedServerName()) - m.logger.Fatal(m.httpServer.Serve(m.YggdrasilNode)) - m.yggListening.Store(false) - }() - } - if m.httpListening.CAS(false, true) { - go func() { - m.logger.Info("Listening on ", m.BaseURL()) - m.logger.Fatal(m.httpServer.Serve(m.listener)) - m.httpListening.Store(false) - }() - } + go func() { + logger.Info("Listening on ", ygg.DerivedServerName()) + logger.Fatal(httpServer.Serve(ygg)) + }() + go func() { + logger.Info("Listening on ", m.BaseURL()) + logger.Fatal(httpServer.Serve(m.listener)) + }() + go func() { + logrus.Info("Sending wake-up message to known nodes") + req := &api.PerformBroadcastEDURequest{} + res := &api.PerformBroadcastEDUResponse{} + if err := fsAPI.PerformBroadcastEDU(context.TODO(), req, res); err != nil { + logrus.WithError(err).Error("Failed to send wake-up message to known nodes") + } + }() } func (m *DendriteMonolith) Suspend() { |