ws: fixed bug in ws codes and now it worked

This commit is contained in:
nadoo committed 2018-07-22 18:21:27 +08:00
1 parent 9856f943ad
commit ff1fb8c291
6 files changed
+61 -56

No files matched your search

+8 -1
View File
@@ -4,6 +4,7 @@ import (
"errors"
"net"
"net/url"
"strings"
"github.com/nadoo/glider/common/log"
"github.com/nadoo/glider/proxy"
@@ -31,7 +32,13 @@ func NewWS(s string, dialer proxy.Dialer) (*WS, error) {
addr := u.Host
client, err := NewClient()
colonPos := strings.LastIndex(addr, ":")
if colonPos == -1 {
colonPos = len(addr)
}
serverName := addr[:colonPos]
client, err := NewClient(serverName, u.Path)
if err != nil {
log.F("create ws client err: %s", err)
return nil, err