mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-20 21:33:19 -06:00
Try to wake up queues on incoming QUIC session
This commit is contained in:
parent
ae827fbe62
commit
b93513a9b4
|
|
@ -122,6 +122,18 @@ func main() {
|
|||
base, federation, rsAPI, stateAPI, keyRing,
|
||||
)
|
||||
|
||||
ygg.SetSessionFunc(func(address string) {
|
||||
req := &api.PerformServersAliveRequest{
|
||||
Servers: []gomatrixserverlib.ServerName{
|
||||
gomatrixserverlib.ServerName(address),
|
||||
},
|
||||
}
|
||||
res := &api.PerformServersAliveResponse{}
|
||||
if err := fsAPI.PerformServersAlive(context.TODO(), req, res); err != nil {
|
||||
logrus.WithError(err).Error("Failed to send wake-up message to newly connected node")
|
||||
}
|
||||
})
|
||||
|
||||
rsComponent.SetFederationSenderAPI(fsAPI)
|
||||
|
||||
embed.Embed(base.BaseMux, *instancePort, "Yggdrasil Demo")
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ type Node struct {
|
|||
quicConfig *quic.Config
|
||||
sessions sync.Map // string -> quic.Session
|
||||
sessionCount atomic.Uint32
|
||||
sessionFunc func(address string)
|
||||
coords sync.Map // string -> yggdrasil.Coords
|
||||
incoming chan QUICStream
|
||||
NewSession func(remote gomatrixserverlib.ServerName)
|
||||
|
|
@ -176,6 +177,10 @@ func (n *Node) SigningPrivateKey() ed25519.PrivateKey {
|
|||
return ed25519.PrivateKey(privBytes)
|
||||
}
|
||||
|
||||
func (n *Node) SetSessionFunc(f func(address string)) {
|
||||
n.sessionFunc = f
|
||||
}
|
||||
|
||||
func (n *Node) PeerCount() int {
|
||||
return len(n.core.GetPeers()) - 1
|
||||
}
|
||||
|
|
@ -186,7 +191,7 @@ func (n *Node) SessionCount() int {
|
|||
|
||||
func (n *Node) KnownNodes() []gomatrixserverlib.ServerName {
|
||||
nodemap := map[string]struct{}{
|
||||
"b5ae50589e50991dd9dd7d59c5c5f7a4521e8da5b603b7f57076272abc58b374": struct{}{},
|
||||
"b5ae50589e50991dd9dd7d59c5c5f7a4521e8da5b603b7f57076272abc58b374": {},
|
||||
}
|
||||
/*
|
||||
for _, peer := range n.core.GetSwitchPeers() {
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ func (n *Node) listenFromYgg() {
|
|||
address := session.ConnectionState().PeerCertificates[0].Subject.CommonName
|
||||
n.log.Infoln("Accepted connection from", address)
|
||||
go n.listenFromQUIC(session, address)
|
||||
go n.sessionFunc(address)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -209,6 +210,7 @@ func (n *Node) tryDial(address string, coords yggdrasil.Coords) (quic.Session, e
|
|||
return nil, fmt.Errorf("expected %q but dialled %q", address, gotAddress)
|
||||
}
|
||||
go n.listenFromQUIC(session, address)
|
||||
go n.sessionFunc(address)
|
||||
return session, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue