mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-13 23:31:34 +00:00
5e85a00cb3
Removes `BaseDendrite` to, hopefully, make testing and composing of components easier in the future.
60 lines
1.4 KiB
Go
60 lines
1.4 KiB
Go
package yggconn
|
|
|
|
import (
|
|
"net/http"
|
|
"time"
|
|
|
|
"github.com/matrix-org/dendrite/setup/config"
|
|
"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() *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.NewClient(
|
|
gomatrixserverlib.WithTransport(tr),
|
|
)
|
|
}
|
|
|
|
func (n *Node) CreateFederationClient(
|
|
cfg *config.Dendrite,
|
|
) *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,
|
|
},
|
|
},
|
|
)
|
|
return gomatrixserverlib.NewFederationClient(
|
|
cfg.Global.SigningIdentities(),
|
|
gomatrixserverlib.WithTransport(tr),
|
|
)
|
|
}
|