Demo tweaks

This commit is contained in:
Neil Alexander 2021-05-24 13:12:05 +01:00
parent 79c5485c8d
commit a7f2845a6a
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944
4 changed files with 6 additions and 14 deletions

View File

@ -97,7 +97,7 @@ func (m *DendriteMonolith) SetStaticPeer(uri string) {
m.staticPeerMutex.Unlock()
m.DisconnectType(pineconeRouter.PeerTypeRemote)
if uri != "" {
m.staticPeerConnect()
go m.staticPeerConnect()
}
}

View File

@ -5,7 +5,6 @@ import (
"net"
"net/http"
"strings"
"time"
"github.com/gorilla/websocket"
"github.com/matrix-org/dendrite/setup"
@ -17,24 +16,15 @@ import (
func ConnectToPeer(pRouter *pineconeRouter.Router, peer string) error {
var parent net.Conn
dialer := net.Dialer{
Timeout: time.Second * 5,
KeepAlive: time.Second * 5,
}
if strings.HasPrefix(peer, "ws://") || strings.HasPrefix(peer, "wss://") {
wsdialer := websocket.Dialer{
NetDial: dialer.Dial,
NetDialContext: dialer.DialContext,
HandshakeTimeout: time.Second * 5,
}
c, _, err := wsdialer.Dial(peer, nil)
c, _, err := websocket.DefaultDialer.Dial(peer, nil)
if err != nil {
return fmt.Errorf("websocket.DefaultDialer.Dial: %w", err)
}
parent = WrapWebSocketConn(c)
} else {
var err error
parent, err = dialer.Dial("tcp", peer)
parent, err = net.Dial("tcp", peer)
if err != nil {
return fmt.Errorf("net.Dial: %w", err)
}

2
go.mod
View File

@ -25,7 +25,7 @@ require (
github.com/matrix-org/gomatrix v0.0.0-20200827122206-7dd5e2a05bcd
github.com/matrix-org/gomatrixserverlib v0.0.0-20210302161955-6142fe3f8c2c
github.com/matrix-org/naffka v0.0.0-20201009174903-d26a3b9cb161
github.com/matrix-org/pinecone v0.0.0-20210524095705-54dc83854438
github.com/matrix-org/pinecone v0.0.0-20210524121048-a698ff38c7c3
github.com/matrix-org/util v0.0.0-20200807132607-55161520e1d4
github.com/mattn/go-sqlite3 v1.14.7-0.20210414154423-1157a4212dcb
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646

2
go.sum
View File

@ -714,6 +714,8 @@ github.com/matrix-org/pinecone v0.0.0-20210518151943-2556e2cf7820 h1:OflgibJOmt1
github.com/matrix-org/pinecone v0.0.0-20210518151943-2556e2cf7820/go.mod h1:UQzJS6UVyVwfkr+RLrdvBB1vLyECqe3fLYNcbRxv8SA=
github.com/matrix-org/pinecone v0.0.0-20210524095705-54dc83854438 h1:pfYBf8db9X8fsieJOUZqv6Evz6YByP+n9rOTzTPC66U=
github.com/matrix-org/pinecone v0.0.0-20210524095705-54dc83854438/go.mod h1:UQzJS6UVyVwfkr+RLrdvBB1vLyECqe3fLYNcbRxv8SA=
github.com/matrix-org/pinecone v0.0.0-20210524121048-a698ff38c7c3 h1:uHQiX47DfRK8TSbrTgT3325RSghCVK0y+JPuRuvvIR4=
github.com/matrix-org/pinecone v0.0.0-20210524121048-a698ff38c7c3/go.mod h1:UQzJS6UVyVwfkr+RLrdvBB1vLyECqe3fLYNcbRxv8SA=
github.com/matrix-org/util v0.0.0-20190711121626-527ce5ddefc7/go.mod h1:vVQlW/emklohkZnOPwD3LrZUBqdfsbiyO3p1lNV8F6U=
github.com/matrix-org/util v0.0.0-20200807132607-55161520e1d4 h1:eCEHXWDv9Rm335MSuB49mFUK44bwZPFSDde3ORE3syk=
github.com/matrix-org/util v0.0.0-20200807132607-55161520e1d4/go.mod h1:vVQlW/emklohkZnOPwD3LrZUBqdfsbiyO3p1lNV8F6U=