Fix bugs in P2P demos

main
Neil Alexander 2021-06-25 15:59:59 +01:00
parent bd7b0b1787
commit a6f7e83596
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944
2 changed files with 11 additions and 4 deletions

View File

@ -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

View File

@ -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)