mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-29 12:42:46 +00:00
Yggdrasil demo initial public room directory (#1181)
* Don't return null to public directory request * Initial support for finding public rooms in Yggdrasil demo (incomplete) * Increase QUIC idle time to 15 minutes
This commit is contained in:
parent
3797c38ec8
commit
3a28ddfb7a
7 changed files with 165 additions and 17 deletions
|
@ -31,6 +31,7 @@ import (
|
|||
|
||||
"github.com/lucas-clemente/quic-go"
|
||||
"github.com/matrix-org/dendrite/cmd/dendrite-demo-yggdrasil/convert"
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
|
||||
yggdrasiladmin "github.com/yggdrasil-network/yggdrasil-go/src/admin"
|
||||
yggdrasilconfig "github.com/yggdrasil-network/yggdrasil-go/src/config"
|
||||
|
@ -140,7 +141,7 @@ func Setup(instanceName, instancePeer, storageDirectory string) (*Node, error) {
|
|||
MaxIncomingStreams: 0,
|
||||
MaxIncomingUniStreams: 0,
|
||||
KeepAlive: true,
|
||||
MaxIdleTimeout: time.Second * 120,
|
||||
MaxIdleTimeout: time.Second * 900,
|
||||
HandshakeTimeout: time.Second * 30,
|
||||
}
|
||||
|
||||
|
@ -183,3 +184,29 @@ func (n *Node) SigningPrivateKey() ed25519.PrivateKey {
|
|||
func (n *Node) PeerCount() int {
|
||||
return len(n.core.GetPeers()) - 1
|
||||
}
|
||||
|
||||
func (n *Node) KnownNodes() []gomatrixserverlib.ServerName {
|
||||
nodemap := map[string]struct{}{}
|
||||
/*
|
||||
for _, peer := range n.core.GetSwitchPeers() {
|
||||
nodemap[hex.EncodeToString(peer.SigningKey[:])] = struct{}{}
|
||||
}
|
||||
*/
|
||||
n.sessions.Range(func(_, v interface{}) bool {
|
||||
session, ok := v.(quic.Session)
|
||||
if !ok {
|
||||
return true
|
||||
}
|
||||
if len(session.ConnectionState().PeerCertificates) != 1 {
|
||||
return true
|
||||
}
|
||||
subjectName := session.ConnectionState().PeerCertificates[0].Subject.CommonName
|
||||
nodemap[subjectName] = struct{}{}
|
||||
return true
|
||||
})
|
||||
var nodes []gomatrixserverlib.ServerName
|
||||
for node := range nodemap {
|
||||
nodes = append(nodes, gomatrixserverlib.ServerName(node))
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
"crypto/rsa"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"crypto/x509/pkix"
|
||||
"encoding/hex"
|
||||
"encoding/pem"
|
||||
"errors"
|
||||
|
@ -127,6 +128,9 @@ func (n *Node) generateTLSConfig() *tls.Config {
|
|||
panic(err)
|
||||
}
|
||||
template := x509.Certificate{
|
||||
Subject: pkix.Name{
|
||||
CommonName: n.DerivedServerName(),
|
||||
},
|
||||
SerialNumber: big.NewInt(1),
|
||||
NotAfter: time.Now().Add(time.Hour * 24 * 365),
|
||||
DNSNames: []string{n.DerivedSessionName()},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue