Add IsSecure() to Transport

This commit is contained in:
Wichert Akkerman
2019-10-11 07:15:47 +02:00
committed by Mickaël Rémond
parent 7fa4b06705
commit 8db608ccc1
4 changed files with 21 additions and 6 deletions
+8 -4
View File
@@ -2,7 +2,6 @@ package xmpp
import (
"context"
"errors"
"net"
"strings"
"time"
@@ -23,9 +22,6 @@ func (t *WebsocketTransport) Connect() error {
ctx, cancel := context.WithTimeout(t.ctx, time.Duration(t.Config.ConnectTimeout)*time.Second)
defer cancel()
if !c.Insecure && strings.HasPrefix(address, "wss:") {
return errors.New("Websocket address is not secure")
}
wsConn, _, err := websocket.Dial(ctx, t.Config.Address, nil)
if err != nil {
t.wsConn = wsConn
@@ -34,10 +30,18 @@ func (t *WebsocketTransport) Connect() error {
return err
}
func (t WebsocketTransport) StartTLS(domain string) error {
return TLSNotSupported
}
func (t WebsocketTransport) DoesStartTLS() bool {
return false
}
func (t WebsocketTransport) IsSecure() bool {
return strings.HasPrefix(t.Config.Address, "wss:")
}
func (t WebsocketTransport) Read(p []byte) (n int, err error) {
return t.netConn.Read(p)
}