mirror of
https://github.com/matrix-org/dendrite
synced 2024-11-01 05:29:08 +01:00
ec716793eb
* Initial federation sender -> federation API refactoring * Move base into own package, avoids import cycle * Fix build errors * Fix tests * Add signing key server tables * Try to fold signing key server into federation API * Fix dendritejs builds * Update embedded interfaces * Fix panic, fix lint error * Update configs, docker * Rename some things * Reuse same keyring on the implementing side * Fix federation tests, `NewBaseDendrite` can accept freeform options * Fix build * Update create_db, configs * Name tables back * Don't rename federationsender consumer for now
62 lines
1.5 KiB
Go
62 lines
1.5 KiB
Go
package yggconn
|
|
|
|
import (
|
|
"net/http"
|
|
"time"
|
|
|
|
"github.com/matrix-org/dendrite/setup/base"
|
|
"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 *base.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.NewClient(
|
|
gomatrixserverlib.WithTransport(tr),
|
|
)
|
|
}
|
|
|
|
func (n *Node) CreateFederationClient(
|
|
base *base.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,
|
|
},
|
|
},
|
|
)
|
|
return gomatrixserverlib.NewFederationClient(
|
|
base.Cfg.Global.ServerName, base.Cfg.Global.KeyID,
|
|
base.Cfg.Global.PrivateKey,
|
|
gomatrixserverlib.WithTransport(tr),
|
|
)
|
|
}
|