From 39005d8fc4389b8913ddc3c16d9aca917b28a46c Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Wed, 26 Apr 2017 10:59:18 +0200 Subject: [PATCH] refactor --- transport/internet/websocket/dialer.go | 7 ++++--- transport/internet/websocket/hub.go | 4 ---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/transport/internet/websocket/dialer.go b/transport/internet/websocket/dialer.go index 1f24f1d1f..27a401b00 100644 --- a/transport/internet/websocket/dialer.go +++ b/transport/internet/websocket/dialer.go @@ -9,15 +9,16 @@ import ( "v2ray.com/core/common" v2net "v2ray.com/core/common/net" "v2ray.com/core/transport/internet" - v2tls "v2ray.com/core/transport/internet/tls" + "v2ray.com/core/transport/internet/tls" ) +// Dial dials a WebSocket connection to the given destination. func Dial(ctx context.Context, dest v2net.Destination) (internet.Connection, error) { log.Trace(newError("creating connection to ", dest)) conn, err := dialWebsocket(ctx, dest) if err != nil { - return nil, newError("dial failed") + return nil, newError("failed to dial WebSocket") } return internet.Connection(conn), nil } @@ -43,7 +44,7 @@ func dialWebsocket(ctx context.Context, dest v2net.Destination) (net.Conn, error protocol := "ws" if securitySettings := internet.SecuritySettingsFromContext(ctx); securitySettings != nil { - tlsConfig, ok := securitySettings.(*v2tls.Config) + tlsConfig, ok := securitySettings.(*tls.Config) if ok { protocol = "wss" dialer.TLSClientConfig = tlsConfig.GetTLSConfig() diff --git a/transport/internet/websocket/hub.go b/transport/internet/websocket/hub.go index a966ebb8a..e6b3281f4 100644 --- a/transport/internet/websocket/hub.go +++ b/transport/internet/websocket/hub.go @@ -17,10 +17,6 @@ import ( v2tls "v2ray.com/core/transport/internet/tls" ) -var ( - ErrClosedListener = newError("Listener is closed.") -) - type requestHandler struct { path string ln *Listener