mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-01 05:42:46 +00:00
Bare QUIC demo working
This commit is contained in:
parent
d3939b3d65
commit
8a5c2020b3
5 changed files with 25 additions and 62 deletions
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue