Set session callbak on gobind build

This commit is contained in:
Neil Alexander 2020-08-05 16:44:20 +01:00
parent b93513a9b4
commit c31ea81482
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -137,6 +137,18 @@ func (m *DendriteMonolith) Start() {
base, federation, rsAPI, stateAPI, keyRing, 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")
}
})
// The underlying roomserver implementation needs to be able to call the fedsender. // The underlying roomserver implementation needs to be able to call the fedsender.
// This is different to rsAPI which can be the http client which doesn't need this dependency // This is different to rsAPI which can be the http client which doesn't need this dependency
rsAPI.SetFederationSenderAPI(fsAPI) rsAPI.SetFederationSenderAPI(fsAPI)
@ -176,8 +188,8 @@ func (m *DendriteMonolith) Start() {
m.httpServer = &http.Server{ m.httpServer = &http.Server{
Addr: ":0", Addr: ":0",
TLSNextProto: map[string]func(*http.Server, *tls.Conn, http.Handler){}, TLSNextProto: map[string]func(*http.Server, *tls.Conn, http.Handler){},
ReadTimeout: 30 * time.Second, ReadTimeout: 15 * time.Second,
WriteTimeout: 30 * time.Second, WriteTimeout: 45 * time.Second,
IdleTimeout: 60 * time.Second, IdleTimeout: 60 * time.Second,
BaseContext: func(_ net.Listener) context.Context { BaseContext: func(_ net.Listener) context.Context {
return context.Background() return context.Background()