Merge pull request #1049 from pdupris/enableSOCKSProxy
Add enableSOCKSProxy option to pass to Starscream WebSockets
This commit is contained in:
		
						commit
						c1744e9e6f
					
				@ -52,6 +52,9 @@ public enum SocketIOClientOption : ClientOption {
 | 
			
		||||
 | 
			
		||||
    /// If passed `true`, the only transport that will be used will be WebSockets.
 | 
			
		||||
    case forceWebsockets(Bool)
 | 
			
		||||
    
 | 
			
		||||
    /// If passed `true`, the WebSocket stream will be configured with the enableSOCKSProxy `true`.
 | 
			
		||||
    case enableSOCKSProxy(Bool)
 | 
			
		||||
 | 
			
		||||
    /// The queue that all interaction with the client should occur on. This is the queue that event handlers are
 | 
			
		||||
    /// called on.
 | 
			
		||||
@ -143,6 +146,8 @@ public enum SocketIOClientOption : ClientOption {
 | 
			
		||||
            description = "security"
 | 
			
		||||
        case .sessionDelegate:
 | 
			
		||||
            description = "sessionDelegate"
 | 
			
		||||
        case .enableSOCKSProxy:
 | 
			
		||||
            description = "enableSOCKSProxy"
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return description
 | 
			
		||||
@ -192,6 +197,8 @@ public enum SocketIOClientOption : ClientOption {
 | 
			
		||||
            value = signed
 | 
			
		||||
        case let .sessionDelegate(delegate):
 | 
			
		||||
            value = delegate
 | 
			
		||||
        case let .enableSOCKSProxy(enable):
 | 
			
		||||
            value = enable
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return value
 | 
			
		||||
 | 
			
		||||
@ -113,6 +113,9 @@ open class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePollable, So
 | 
			
		||||
    /// If `true`, then the engine is currently in WebSockets mode.
 | 
			
		||||
    @available(*, deprecated, message: "No longer needed, if we're not polling, then we must be doing websockets")
 | 
			
		||||
    public private(set) var websocket = false
 | 
			
		||||
    
 | 
			
		||||
    /// When `true`, the WebSocket `stream` will be configured with the enableSOCKSProxy `true`.
 | 
			
		||||
    public private(set) var enableSOCKSProxy = false
 | 
			
		||||
 | 
			
		||||
    /// The WebSocket for this engine.
 | 
			
		||||
    public private(set) var ws: WebSocket?
 | 
			
		||||
@ -283,7 +286,9 @@ open class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePollable, So
 | 
			
		||||
 | 
			
		||||
        addHeaders(to: &req, includingCookies: session?.configuration.httpCookieStorage?.cookies(for: urlPollingWithSid))
 | 
			
		||||
 | 
			
		||||
        ws = WebSocket(request: req)
 | 
			
		||||
        let stream = FoundationStream()
 | 
			
		||||
        stream.enableSOCKSProxy = enableSOCKSProxy
 | 
			
		||||
        ws = WebSocket(request: req, stream: stream)
 | 
			
		||||
        ws?.callbackQueue = engineQueue
 | 
			
		||||
        ws?.enableCompression = compress
 | 
			
		||||
        ws?.disableSSLCertValidation = selfSigned
 | 
			
		||||
@ -593,6 +598,8 @@ open class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePollable, So
 | 
			
		||||
                self.security = security
 | 
			
		||||
            case .compress:
 | 
			
		||||
                self.compress = true
 | 
			
		||||
            case .enableSOCKSProxy:
 | 
			
		||||
                self.enableSOCKSProxy = true
 | 
			
		||||
            default:
 | 
			
		||||
                continue
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
@ -85,6 +85,8 @@ extension Dictionary where Key == String, Value == Any {
 | 
			
		||||
            return .sessionDelegate(delegate)
 | 
			
		||||
        case let ("compress", compress as Bool):
 | 
			
		||||
            return compress ? .compress : nil
 | 
			
		||||
        case let ("enableSOCKSProxy", enable as Bool):
 | 
			
		||||
            return .enableSOCKSProxy(enable)
 | 
			
		||||
        default:
 | 
			
		||||
            return nil
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user