From a6f7e835968e1a1123f1b03bce70994599ac8848 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Fri, 25 Jun 2021 15:59:59 +0100 Subject: [PATCH] Fix bugs in P2P demos --- cmd/dendrite-demo-pinecone/conn/client.go | 12 +++++++++--- cmd/dendritejs-pinecone/main.go | 3 ++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/cmd/dendrite-demo-pinecone/conn/client.go b/cmd/dendrite-demo-pinecone/conn/client.go index 0889e781..5ba8e8ec 100644 --- a/cmd/dendrite-demo-pinecone/conn/client.go +++ b/cmd/dendrite-demo-pinecone/conn/client.go @@ -21,7 +21,7 @@ func ConnectToPeer(pRouter *pineconeRouter.Router, peer string) error { ctx := context.Background() c, _, err := websocket.Dial(ctx, peer, nil) if err != nil { - return fmt.Errorf("websocket.Dial: %w", err) + return fmt.Errorf("websocket.DefaultDialer.Dial: %w", err) } parent = websocket.NetConn(ctx, c, websocket.MessageBinary) } else { @@ -43,7 +43,7 @@ type RoundTripper struct { } func (y *RoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { - req.URL.Scheme = "https" + req.URL.Scheme = "http" return y.inner.RoundTrip(req) } @@ -57,7 +57,13 @@ func createTransport(s *pineconeSessions.Sessions) *http.Transport { } tr.RegisterProtocol( "matrix", &RoundTripper{ - inner: tr, + inner: &http.Transport{ + DisableKeepAlives: false, + Dial: s.Dial, + DialContext: s.DialContext, + DialTLS: s.DialTLS, + DialTLSContext: s.DialTLSContext, + }, }, ) return tr diff --git a/cmd/dendritejs-pinecone/main.go b/cmd/dendritejs-pinecone/main.go index f4c8a982..433e9bf8 100644 --- a/cmd/dendritejs-pinecone/main.go +++ b/cmd/dendritejs-pinecone/main.go @@ -18,6 +18,7 @@ package main import ( "crypto/ed25519" + "encoding/hex" "fmt" "log" "os" @@ -166,7 +167,7 @@ func main() { cfg.Global.TrustedIDServers = []string{} cfg.Global.KeyID = gomatrixserverlib.KeyID(signing.KeyID) cfg.Global.PrivateKey = sk - cfg.Global.ServerName = gomatrixserverlib.ServerName(pk) + cfg.Global.ServerName = gomatrixserverlib.ServerName(hex.EncodeToString(pk)) if err := cfg.Derive(); err != nil { logrus.Fatalf("Failed to derive values from config: %s", err)