mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-26 08:13:09 -06:00
Functions instead
This commit is contained in:
parent
2cd06f8c92
commit
9f9404c4e8
|
|
@ -79,9 +79,7 @@ func createFederationClient(
|
|||
return gomatrixserverlib.NewFederationClient(
|
||||
base.Base.Cfg.Global.ServerName, base.Base.Cfg.Global.KeyID,
|
||||
base.Base.Cfg.Global.PrivateKey, true,
|
||||
gomatrixserverlib.WithTransport{
|
||||
Transport: tr,
|
||||
},
|
||||
gomatrixserverlib.WithTransport(tr),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -94,9 +92,7 @@ func createClient(
|
|||
p2phttp.NewTransport(base.LibP2P, p2phttp.ProtocolOption("/matrix")),
|
||||
)
|
||||
return gomatrixserverlib.NewClient(
|
||||
gomatrixserverlib.WithTransport{
|
||||
Transport: tr,
|
||||
},
|
||||
gomatrixserverlib.WithTransport(tr),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,9 +34,7 @@ func (n *Node) CreateClient(
|
|||
},
|
||||
)
|
||||
return gomatrixserverlib.NewClient(
|
||||
gomatrixserverlib.WithTransport{
|
||||
Transport: tr,
|
||||
},
|
||||
gomatrixserverlib.WithTransport(tr),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -60,8 +58,6 @@ func (n *Node) CreateFederationClient(
|
|||
return gomatrixserverlib.NewFederationClient(
|
||||
base.Cfg.Global.ServerName, base.Cfg.Global.KeyID,
|
||||
base.Cfg.Global.PrivateKey, true,
|
||||
gomatrixserverlib.WithTransport{
|
||||
Transport: tr,
|
||||
},
|
||||
gomatrixserverlib.WithTransport(tr),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,9 +140,7 @@ func createFederationClient(cfg *config.Dendrite, node *go_http_js_libp2p.P2pLoc
|
|||
|
||||
fed := gomatrixserverlib.NewFederationClient(
|
||||
cfg.Global.ServerName, cfg.Global.KeyID, cfg.Global.PrivateKey, true,
|
||||
gomatrixserverlib.WithTransport{
|
||||
Transport: tr,
|
||||
},
|
||||
gomatrixserverlib.WithTransport(tr),
|
||||
)
|
||||
|
||||
return fed
|
||||
|
|
@ -151,9 +149,7 @@ func createFederationClient(cfg *config.Dendrite, node *go_http_js_libp2p.P2pLoc
|
|||
func createClient(node *go_http_js_libp2p.P2pLocalNode) *gomatrixserverlib.Client {
|
||||
tr := go_http_js_libp2p.NewP2pTransport(node)
|
||||
return gomatrixserverlib.NewClient(
|
||||
gomatrixserverlib.WithTransport{
|
||||
Transport: tr,
|
||||
},
|
||||
gomatrixserverlib.WithTransport(tr),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,9 +38,7 @@ func TestRoomsV3URLEscapeDoNot404(t *testing.T) {
|
|||
|
||||
fedCli := gomatrixserverlib.NewFederationClient(
|
||||
serverName, cfg.Global.KeyID, cfg.Global.PrivateKey, true,
|
||||
gomatrixserverlib.WithSkipVerify{
|
||||
SkipVerify: true,
|
||||
},
|
||||
gomatrixserverlib.WithSkipVerify(true),
|
||||
)
|
||||
|
||||
testCases := []struct {
|
||||
|
|
|
|||
2
go.mod
2
go.mod
|
|
@ -22,7 +22,7 @@ require (
|
|||
github.com/matrix-org/go-http-js-libp2p v0.0.0-20200518170932-783164aeeda4
|
||||
github.com/matrix-org/go-sqlite3-js v0.0.0-20200522092705-bc8506ccbcf3
|
||||
github.com/matrix-org/gomatrix v0.0.0-20200827122206-7dd5e2a05bcd
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20210122145212-a95dacb6fbfe
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20210122151513-242af9ecccdc
|
||||
github.com/matrix-org/naffka v0.0.0-20200901083833-bcdd62999a91
|
||||
github.com/matrix-org/util v0.0.0-20200807132607-55161520e1d4
|
||||
github.com/mattn/go-sqlite3 v1.14.2
|
||||
|
|
|
|||
4
go.sum
4
go.sum
|
|
@ -567,8 +567,8 @@ github.com/matrix-org/gomatrix v0.0.0-20190528120928-7df988a63f26 h1:Hr3zjRsq2bh
|
|||
github.com/matrix-org/gomatrix v0.0.0-20190528120928-7df988a63f26/go.mod h1:3fxX6gUjWyI/2Bt7J1OLhpCzOfO/bB3AiX0cJtEKud0=
|
||||
github.com/matrix-org/gomatrix v0.0.0-20200827122206-7dd5e2a05bcd h1:xVrqJK3xHREMNjwjljkAUaadalWc0rRbmVuQatzmgwg=
|
||||
github.com/matrix-org/gomatrix v0.0.0-20200827122206-7dd5e2a05bcd/go.mod h1:/gBX06Kw0exX1HrwmoBibFA98yBk/jxKpGVeyQbff+s=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20210122145212-a95dacb6fbfe h1:ra5KEAStTQ9RuML7ZBAnUndlVJ34pqydbjJ13KgiJ+8=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20210122145212-a95dacb6fbfe/go.mod h1:JsAzE1Ll3+gDWS9JSUHPJiiyAksvOOnGWF2nXdg4ZzU=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20210122151513-242af9ecccdc h1:0Xv8GPLZk6vBsOdKRVUMA/XMR+lmc5GfI7YUulhou7k=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20210122151513-242af9ecccdc/go.mod h1:JsAzE1Ll3+gDWS9JSUHPJiiyAksvOOnGWF2nXdg4ZzU=
|
||||
github.com/matrix-org/naffka v0.0.0-20200901083833-bcdd62999a91 h1:HJ6U3S3ljJqNffYMcIeAncp5qT/i+ZMiJ2JC2F0aXP4=
|
||||
github.com/matrix-org/naffka v0.0.0-20200901083833-bcdd62999a91/go.mod h1:sjyPyRxKM5uw1nD2cJ6O2OxI6GOqyVBfNXqKjBZTBZE=
|
||||
github.com/matrix-org/util v0.0.0-20190711121626-527ce5ddefc7 h1:ntrLa/8xVzeSs8vHFHK25k0C+NV74sYMJnNSg5NoSRo=
|
||||
|
|
|
|||
|
|
@ -109,9 +109,7 @@ func newFedClient(tripper func(*http.Request) (*http.Response, error)) *gomatrix
|
|||
gomatrixserverlib.ServerName("example.test"), gomatrixserverlib.KeyID("ed25519:test"), pkey, true,
|
||||
)
|
||||
fedClient.Client = *gomatrixserverlib.NewClient(
|
||||
gomatrixserverlib.WithTransport{
|
||||
Transport: &roundTripper{tripper},
|
||||
},
|
||||
gomatrixserverlib.WithTransport(&roundTripper{tripper}),
|
||||
)
|
||||
return fedClient
|
||||
}
|
||||
|
|
|
|||
|
|
@ -267,17 +267,15 @@ func (b *BaseDendrite) CreateAccountsDB() accounts.Database {
|
|||
func (b *BaseDendrite) CreateClient() *gomatrixserverlib.Client {
|
||||
if b.Cfg.Global.DisableFederation {
|
||||
return gomatrixserverlib.NewClient(
|
||||
gomatrixserverlib.WithTransport{
|
||||
Transport: noOpHTTPTransport,
|
||||
},
|
||||
gomatrixserverlib.WithTransport(noOpHTTPTransport),
|
||||
)
|
||||
}
|
||||
opts := []gomatrixserverlib.ClientOption{}
|
||||
if b.Cfg.Global.DNSCache.Enabled {
|
||||
opts = append(opts, gomatrixserverlib.WithDNSCache{DNSCache: b.DNSCache})
|
||||
opts = append(opts, gomatrixserverlib.WithDNSCache(b.DNSCache))
|
||||
}
|
||||
if validation := b.Cfg.FederationSender.DisableTLSValidation; validation {
|
||||
opts = append(opts, gomatrixserverlib.WithSkipVerify{SkipVerify: validation})
|
||||
opts = append(opts, gomatrixserverlib.WithSkipVerify(validation))
|
||||
}
|
||||
client := gomatrixserverlib.NewClient(opts...)
|
||||
client.SetUserAgent(fmt.Sprintf("Dendrite/%s", internal.VersionString()))
|
||||
|
|
@ -291,20 +289,14 @@ func (b *BaseDendrite) CreateFederationClient() *gomatrixserverlib.FederationCli
|
|||
return gomatrixserverlib.NewFederationClient(
|
||||
b.Cfg.Global.ServerName, b.Cfg.Global.KeyID,
|
||||
b.Cfg.Global.PrivateKey, b.Cfg.FederationSender.DisableTLSValidation,
|
||||
gomatrixserverlib.WithTransport{
|
||||
Transport: noOpHTTPTransport,
|
||||
},
|
||||
gomatrixserverlib.WithTransport(noOpHTTPTransport),
|
||||
)
|
||||
}
|
||||
opts := []gomatrixserverlib.ClientOption{
|
||||
gomatrixserverlib.WithTimeout{
|
||||
Timeout: time.Minute * 5,
|
||||
},
|
||||
gomatrixserverlib.WithTimeout(time.Minute * 5),
|
||||
}
|
||||
if b.Cfg.Global.DNSCache.Enabled {
|
||||
opts = append(opts, gomatrixserverlib.WithDNSCache{
|
||||
DNSCache: b.DNSCache,
|
||||
})
|
||||
opts = append(opts, gomatrixserverlib.WithDNSCache(b.DNSCache))
|
||||
}
|
||||
client := gomatrixserverlib.NewFederationClient(
|
||||
b.Cfg.Global.ServerName, b.Cfg.Global.KeyID, b.Cfg.Global.PrivateKey,
|
||||
|
|
|
|||
|
|
@ -89,9 +89,7 @@ func TestMain(m *testing.M) {
|
|||
// Create the federation client.
|
||||
s.fedclient = gomatrixserverlib.NewFederationClient(
|
||||
s.config.Matrix.ServerName, serverKeyID, testPriv, true,
|
||||
gomatrixserverlib.WithTransport{
|
||||
Transport: transport,
|
||||
},
|
||||
gomatrixserverlib.WithTransport(transport),
|
||||
)
|
||||
|
||||
// Finally, build the server key APIs.
|
||||
|
|
|
|||
Loading…
Reference in a new issue