diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2022-09-12 10:19:02 +0100 |
---|---|---|
committer | Neil Alexander <neilalexander@users.noreply.github.com> | 2022-09-12 10:19:02 +0100 |
commit | 3a9dde28fda81067a2127258b09ff7c9accd5256 (patch) | |
tree | 4f77ac45a28e31d68108d365a606766b2f8171bd /cmd | |
parent | 5997c3245286b4a8df57054b1f311e5957836910 (diff) |
P2P demo tweaks
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/dendrite-demo-pinecone/main.go | 10 | ||||
-rw-r--r-- | cmd/dendrite-demo-yggdrasil/main.go | 9 |
2 files changed, 17 insertions, 2 deletions
diff --git a/cmd/dendrite-demo-pinecone/main.go b/cmd/dendrite-demo-pinecone/main.go index 83b52132..ff9cb5aa 100644 --- a/cmd/dendrite-demo-pinecone/main.go +++ b/cmd/dendrite-demo-pinecone/main.go @@ -98,6 +98,9 @@ func main() { if _, sk, err = config.LoadMatrixKey(keyfile, os.ReadFile); err != nil { panic("failed to load PEM key: " + err.Error()) } + if len(sk) != ed25519.PrivateKeySize { + panic("the private key is not long enough") + } } else { if sk, err = os.ReadFile(oldkeyfile); err != nil { panic("failed to read the old private key: " + err.Error()) @@ -114,7 +117,13 @@ func main() { if _, sk, err = config.LoadMatrixKey(keyfile, os.ReadFile); err != nil { panic("failed to load PEM key: " + err.Error()) } + if len(sk) != ed25519.PrivateKeySize { + panic("the private key is not long enough") + } } + + pk = sk.Public().(ed25519.PublicKey) + cfg.Defaults(config.DefaultOpts{ Generate: true, Monolithic: true, @@ -136,7 +145,6 @@ func main() { } } - pk = sk.Public().(ed25519.PublicKey) cfg.Global.ServerName = gomatrixserverlib.ServerName(hex.EncodeToString(pk)) cfg.Global.KeyID = gomatrixserverlib.KeyID(signing.KeyID) diff --git a/cmd/dendrite-demo-yggdrasil/main.go b/cmd/dendrite-demo-yggdrasil/main.go index 7445b6bf..868d9826 100644 --- a/cmd/dendrite-demo-yggdrasil/main.go +++ b/cmd/dendrite-demo-yggdrasil/main.go @@ -86,6 +86,9 @@ func main() { if _, sk, err = config.LoadMatrixKey(keyfile, os.ReadFile); err != nil { panic("failed to load PEM key: " + err.Error()) } + if len(sk) != ed25519.PrivateKeySize { + panic("the private key is not long enough") + } } else { if sk, err = os.ReadFile(oldkeyfile); err != nil { panic("failed to read the old private key: " + err.Error()) @@ -102,8 +105,13 @@ func main() { if _, sk, err = config.LoadMatrixKey(keyfile, os.ReadFile); err != nil { panic("failed to load PEM key: " + err.Error()) } + if len(sk) != ed25519.PrivateKeySize { + panic("the private key is not long enough") + } } + pk = sk.Public().(ed25519.PublicKey) + // use custom config if config flag is set if configFlagSet { cfg = setup.ParseFlags(true) @@ -129,7 +137,6 @@ func main() { } } - pk = sk.Public().(ed25519.PublicKey) cfg.Global.ServerName = gomatrixserverlib.ServerName(hex.EncodeToString(pk)) cfg.Global.KeyID = gomatrixserverlib.KeyID(signing.KeyID) |