Bare QUIC demo working

This commit is contained in:
Neil Alexander 2020-07-16 13:42:10 +01:00
parent d3939b3d65
commit 8a5c2020b3
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
5 changed files with 25 additions and 62 deletions

View file

@ -24,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"
)
type DendriteMonolith struct {
@ -162,32 +161,6 @@ func (m *DendriteMonolith) Start() {
base.UseHTTPAPIs,
)
ygg.NotifySessionNew(func(boxPubKey crypto.BoxPubKey) {
serv := gomatrixserverlib.ServerName(boxPubKey.String())
req := &api.PerformServersAliveRequest{
Servers: []gomatrixserverlib.ServerName{serv},
}
res := &api.PerformServersAliveResponse{}
if err := fsAPI.PerformServersAlive(context.TODO(), req, res); err != nil {
logrus.WithError(err).Warnf("Failed to notify server %q alive due to new session", serv)
} else {
logrus.Infof("Notified server %q alive due to new session", serv)
}
})
ygg.NotifyLinkNew(func(boxPubKey crypto.BoxPubKey, linkType, remote string) {
serv := gomatrixserverlib.ServerName(boxPubKey.String())
req := &api.PerformServersAliveRequest{
Servers: []gomatrixserverlib.ServerName{serv},
}
res := &api.PerformServersAliveResponse{}
if err := fsAPI.PerformServersAlive(context.TODO(), req, res); err != nil {
logrus.WithError(err).Warnf("Failed to notify server %q alive due to new peer", serv)
} else {
logrus.Infof("Notified server %q alive due to new peer", serv)
}
})
// Build both ends of a HTTP multiplex.
httpServer := &http.Server{
Addr: ":0",
@ -209,6 +182,14 @@ func (m *DendriteMonolith) Start() {
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) Stop() {