Explorar el Código

Support Dial WebSocket Connection

Shelikhoo hace 9 años
padre
commit
29f69d63c4
Se han modificado 1 ficheros con 12 adiciones y 0 borrados
  1. 12 0
      transport/internet/dialer.go

+ 12 - 0
transport/internet/dialer.go

@@ -20,9 +20,11 @@ var (
 	KCPDialer    Dialer
 	RawTCPDialer Dialer
 	UDPDialer    Dialer
+	WSDialer     Dialer
 )
 
 func Dial(src v2net.Address, dest v2net.Destination, settings *StreamSettings) (Connection, error) {
+
 	var connection Connection
 	var err error
 	if dest.IsTCP() {
@@ -31,6 +33,15 @@ func Dial(src v2net.Address, dest v2net.Destination, settings *StreamSettings) (
 			connection, err = TCPDialer(src, dest)
 		case settings.IsCapableOf(StreamConnectionTypeKCP):
 			connection, err = KCPDialer(src, dest)
+		case settings.IsCapableOf(StreamConnectionTypeWebSocket):
+			connection, err = WSDialer(src, dest)
+
+		/*Warning: Hours wasted: the following item must be last one
+
+		internet.StreamConnectionType have a default value of 1,
+		so the following attempt will catch all.
+		*/
+
 		case settings.IsCapableOf(StreamConnectionTypeRawTCP):
 			connection, err = RawTCPDialer(src, dest)
 		default:
@@ -39,6 +50,7 @@ func Dial(src v2net.Address, dest v2net.Destination, settings *StreamSettings) (
 		if err != nil {
 			return nil, err
 		}
+
 		if settings.Security == StreamSecurityTypeNone {
 			return connection, nil
 		}