aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2022-11-15 15:05:23 +0000
committerNeil Alexander <neilalexander@users.noreply.github.com>2022-11-15 15:05:23 +0000
commit6650712a1c0dec282b47b7ba14bc8c2e06a385d8 (patch)
tree12ca755c5c33d3489417f9355dda3f1b7983c779 /cmd
parentf4ee3977340c84d321767d347795b1dcd05ac459 (diff)
Federation fixes for virtual hosting
Diffstat (limited to 'cmd')
-rw-r--r--cmd/dendrite-demo-pinecone/conn/client.go4
-rw-r--r--cmd/dendrite-demo-pinecone/rooms/rooms.go8
-rw-r--r--cmd/dendrite-demo-yggdrasil/yggconn/client.go3
-rw-r--r--cmd/dendrite-demo-yggdrasil/yggrooms/yggrooms.go9
-rw-r--r--cmd/furl/main.go12
5 files changed, 24 insertions, 12 deletions
diff --git a/cmd/dendrite-demo-pinecone/conn/client.go b/cmd/dendrite-demo-pinecone/conn/client.go
index 27e18c2a..a91434f6 100644
--- a/cmd/dendrite-demo-pinecone/conn/client.go
+++ b/cmd/dendrite-demo-pinecone/conn/client.go
@@ -101,9 +101,7 @@ func CreateFederationClient(
base *base.BaseDendrite, s *pineconeSessions.Sessions,
) *gomatrixserverlib.FederationClient {
return gomatrixserverlib.NewFederationClient(
- base.Cfg.Global.ServerName,
- base.Cfg.Global.KeyID,
- base.Cfg.Global.PrivateKey,
+ base.Cfg.Global.SigningIdentities(),
gomatrixserverlib.WithTransport(createTransport(s)),
)
}
diff --git a/cmd/dendrite-demo-pinecone/rooms/rooms.go b/cmd/dendrite-demo-pinecone/rooms/rooms.go
index 0fafbedc..0ac705cc 100644
--- a/cmd/dendrite-demo-pinecone/rooms/rooms.go
+++ b/cmd/dendrite-demo-pinecone/rooms/rooms.go
@@ -58,13 +58,17 @@ func (p *PineconeRoomProvider) Rooms() []gomatrixserverlib.PublicRoom {
for _, k := range p.r.Peers() {
list[gomatrixserverlib.ServerName(k.PublicKey)] = struct{}{}
}
- return bulkFetchPublicRoomsFromServers(context.Background(), p.fedClient, list)
+ return bulkFetchPublicRoomsFromServers(
+ context.Background(), p.fedClient,
+ gomatrixserverlib.ServerName(p.r.PublicKey().String()), list,
+ )
}
// bulkFetchPublicRoomsFromServers fetches public rooms from the list of homeservers.
// Returns a list of public rooms.
func bulkFetchPublicRoomsFromServers(
ctx context.Context, fedClient *gomatrixserverlib.FederationClient,
+ origin gomatrixserverlib.ServerName,
homeservers map[gomatrixserverlib.ServerName]struct{},
) (publicRooms []gomatrixserverlib.PublicRoom) {
limit := 200
@@ -82,7 +86,7 @@ func bulkFetchPublicRoomsFromServers(
go func(homeserverDomain gomatrixserverlib.ServerName) {
defer wg.Done()
util.GetLogger(reqctx).WithField("hs", homeserverDomain).Info("Querying HS for public rooms")
- fres, err := fedClient.GetPublicRooms(reqctx, homeserverDomain, int(limit), "", false, "")
+ fres, err := fedClient.GetPublicRooms(reqctx, origin, homeserverDomain, int(limit), "", false, "")
if err != nil {
util.GetLogger(reqctx).WithError(err).WithField("hs", homeserverDomain).Warn(
"bulkFetchPublicRoomsFromServers: failed to query hs",
diff --git a/cmd/dendrite-demo-yggdrasil/yggconn/client.go b/cmd/dendrite-demo-yggdrasil/yggconn/client.go
index 358d3725..41a9ec12 100644
--- a/cmd/dendrite-demo-yggdrasil/yggconn/client.go
+++ b/cmd/dendrite-demo-yggdrasil/yggconn/client.go
@@ -55,8 +55,7 @@ func (n *Node) CreateFederationClient(
},
)
return gomatrixserverlib.NewFederationClient(
- base.Cfg.Global.ServerName, base.Cfg.Global.KeyID,
- base.Cfg.Global.PrivateKey,
+ base.Cfg.Global.SigningIdentities(),
gomatrixserverlib.WithTransport(tr),
)
}
diff --git a/cmd/dendrite-demo-yggdrasil/yggrooms/yggrooms.go b/cmd/dendrite-demo-yggdrasil/yggrooms/yggrooms.go
index 402b86ed..0de64755 100644
--- a/cmd/dendrite-demo-yggdrasil/yggrooms/yggrooms.go
+++ b/cmd/dendrite-demo-yggdrasil/yggrooms/yggrooms.go
@@ -43,13 +43,18 @@ func NewYggdrasilRoomProvider(
}
func (p *YggdrasilRoomProvider) Rooms() []gomatrixserverlib.PublicRoom {
- return bulkFetchPublicRoomsFromServers(context.Background(), p.fedClient, p.node.KnownNodes())
+ return bulkFetchPublicRoomsFromServers(
+ context.Background(), p.fedClient,
+ gomatrixserverlib.ServerName(p.node.DerivedServerName()),
+ p.node.KnownNodes(),
+ )
}
// bulkFetchPublicRoomsFromServers fetches public rooms from the list of homeservers.
// Returns a list of public rooms.
func bulkFetchPublicRoomsFromServers(
ctx context.Context, fedClient *gomatrixserverlib.FederationClient,
+ origin gomatrixserverlib.ServerName,
homeservers []gomatrixserverlib.ServerName,
) (publicRooms []gomatrixserverlib.PublicRoom) {
limit := 200
@@ -66,7 +71,7 @@ func bulkFetchPublicRoomsFromServers(
go func(homeserverDomain gomatrixserverlib.ServerName) {
defer wg.Done()
util.GetLogger(ctx).WithField("hs", homeserverDomain).Info("Querying HS for public rooms")
- fres, err := fedClient.GetPublicRooms(ctx, homeserverDomain, int(limit), "", false, "")
+ fres, err := fedClient.GetPublicRooms(ctx, origin, homeserverDomain, int(limit), "", false, "")
if err != nil {
util.GetLogger(ctx).WithError(err).WithField("hs", homeserverDomain).Warn(
"bulkFetchPublicRoomsFromServers: failed to query hs",
diff --git a/cmd/furl/main.go b/cmd/furl/main.go
index f59f9c8c..b208ba86 100644
--- a/cmd/furl/main.go
+++ b/cmd/furl/main.go
@@ -48,10 +48,15 @@ func main() {
panic("unexpected key block")
}
+ serverName := gomatrixserverlib.ServerName(*requestFrom)
client := gomatrixserverlib.NewFederationClient(
- gomatrixserverlib.ServerName(*requestFrom),
- gomatrixserverlib.KeyID(keyBlock.Headers["Key-ID"]),
- privateKey,
+ []*gomatrixserverlib.SigningIdentity{
+ {
+ ServerName: serverName,
+ KeyID: gomatrixserverlib.KeyID(keyBlock.Headers["Key-ID"]),
+ PrivateKey: privateKey,
+ },
+ },
)
u, err := url.Parse(flag.Arg(0))
@@ -79,6 +84,7 @@ func main() {
req := gomatrixserverlib.NewFederationRequest(
method,
+ serverName,
gomatrixserverlib.ServerName(u.Host),
u.RequestURI(),
)