mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-13 23:31:34 +00:00
b7491aae03
* PerformServersAlive in PerformBroadcastEDU * Don't double-pointer * More reliable QUIC session handling * Direct peer lookup, other tweaks * Tweaks * Try to wake up queues on incoming QUIC session * Set session callbak on gobind build * Fix incoming session storage * Stateless reset, other tweaks * Reset sessions when coordinates change * Disable HTTP connection reuse, tweak timeouts
60 lines
1.5 KiB
Go
60 lines
1.5 KiB
Go
package yggconn
|
|
|
|
import (
|
|
"net/http"
|
|
"time"
|
|
|
|
"github.com/matrix-org/dendrite/internal/setup"
|
|
"github.com/matrix-org/gomatrixserverlib"
|
|
)
|
|
|
|
type yggroundtripper struct {
|
|
inner *http.Transport
|
|
}
|
|
|
|
func (y *yggroundtripper) RoundTrip(req *http.Request) (*http.Response, error) {
|
|
req.URL.Scheme = "http"
|
|
return y.inner.RoundTrip(req)
|
|
}
|
|
|
|
func (n *Node) CreateClient(
|
|
base *setup.BaseDendrite,
|
|
) *gomatrixserverlib.Client {
|
|
tr := &http.Transport{}
|
|
tr.RegisterProtocol(
|
|
"matrix", &yggroundtripper{
|
|
inner: &http.Transport{
|
|
MaxIdleConns: -1,
|
|
MaxIdleConnsPerHost: -1,
|
|
TLSHandshakeTimeout: 10 * time.Second,
|
|
ResponseHeaderTimeout: 10 * time.Second,
|
|
IdleConnTimeout: 30 * time.Second,
|
|
DialContext: n.DialerContext,
|
|
},
|
|
},
|
|
)
|
|
return gomatrixserverlib.NewClientWithTransport(tr)
|
|
}
|
|
|
|
func (n *Node) CreateFederationClient(
|
|
base *setup.BaseDendrite,
|
|
) *gomatrixserverlib.FederationClient {
|
|
tr := &http.Transport{}
|
|
tr.RegisterProtocol(
|
|
"matrix", &yggroundtripper{
|
|
inner: &http.Transport{
|
|
MaxIdleConns: -1,
|
|
MaxIdleConnsPerHost: -1,
|
|
TLSHandshakeTimeout: 10 * time.Second,
|
|
ResponseHeaderTimeout: 10 * time.Second,
|
|
IdleConnTimeout: 30 * time.Second,
|
|
DialContext: n.DialerContext,
|
|
TLSClientConfig: n.tlsConfig,
|
|
},
|
|
},
|
|
)
|
|
return gomatrixserverlib.NewFederationClientWithTransport(
|
|
base.Cfg.Matrix.ServerName, base.Cfg.Matrix.KeyID, base.Cfg.Matrix.PrivateKey, tr,
|
|
)
|
|
}
|