From 3f9eb137d06238394cb11bbac26c9de745bae443 Mon Sep 17 00:00:00 2001 From: Lita Date: Tue, 15 May 2018 12:04:05 -0500 Subject: [PATCH] Sometimes Things Need to be Public >.< --- Sources/Meek/MeekTCPConnection.swift | 52 ++++++++++++++-------------- Sources/Wisp/WispTCPConnection.swift | 38 ++++++++++---------- 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/Sources/Meek/MeekTCPConnection.swift b/Sources/Meek/MeekTCPConnection.swift index f02566f..b06de79 100644 --- a/Sources/Meek/MeekTCPConnection.swift +++ b/Sources/Meek/MeekTCPConnection.swift @@ -25,9 +25,9 @@ func createMeekTCPConnection(provider: PacketTunnelProvider, to: URL, serverURL: return c } -class MeekTCPConnection: TCPConnection +public class MeekTCPConnection: TCPConnection { - var hasBetterPath: Bool + public var hasBetterPath: Bool { get { @@ -35,7 +35,7 @@ class MeekTCPConnection: TCPConnection } } - var endpoint: NWEndpoint + public var endpoint: NWEndpoint { get { @@ -43,29 +43,29 @@ class MeekTCPConnection: TCPConnection } } - var connectedPath: NWPath? + public var connectedPath: NWPath? - var localAddress: NWEndpoint? + public var localAddress: NWEndpoint? - var remoteAddress: NWEndpoint? + public var remoteAddress: NWEndpoint? - var txtRecord: Data? + public var txtRecord: Data? - var error: Error? + public var error: Error? - var serverURL: URL - var frontURL: URL - var network: TCPConnection - var bodyBuffer = Data() - var sessionID = "" + public var serverURL: URL + public var frontURL: URL + public var network: TCPConnection + public var bodyBuffer = Data() + public var sessionID = "" ///Meek server is no longer accepting POST - var meekIsClosed = false + public var meekIsClosed = false let minLength = 1 let maxLength = MemoryLayout.size - enum MeekError: Error + public enum MeekError: Error { case unknownError case connectionError @@ -79,7 +79,7 @@ class MeekTCPConnection: TCPConnection case unsuppotedURL } - var isViable: Bool + public var isViable: Bool { get { @@ -87,7 +87,7 @@ class MeekTCPConnection: TCPConnection } } - var state: NWTCPConnectionState + public var state: NWTCPConnectionState { get { @@ -95,7 +95,7 @@ class MeekTCPConnection: TCPConnection } } - var stateCallback: ((NWTCPConnectionState, Error?) -> Void)? + public var stateCallback: ((NWTCPConnectionState, Error?) -> Void)? private var _isViable: Bool private var _error: Error? @@ -111,7 +111,7 @@ class MeekTCPConnection: TCPConnection } } - init?(provider: PacketTunnelProvider, to front: URL, url: URL) + public init?(provider: PacketTunnelProvider, to front: URL, url: URL) { serverURL = url frontURL = front @@ -131,12 +131,12 @@ class MeekTCPConnection: TCPConnection sessionID = generateSessionID() ?? "" } - func observeState(_ callback: @escaping (NWTCPConnectionState, Error?) -> Void) { + public func observeState(_ callback: @escaping (NWTCPConnectionState, Error?) -> Void) { self.stateCallback=callback } // Currrently this function ignores the minimum and maximum lengths provided. - func readMinimumLength(_ minimum: Int, maximumLength maximum: Int, completionHandler completion: @escaping (Data?, Error?) -> Void) + public func readMinimumLength(_ minimum: Int, maximumLength maximum: Int, completionHandler completion: @escaping (Data?, Error?) -> Void) { guard isViable else @@ -182,12 +182,12 @@ class MeekTCPConnection: TCPConnection } } - func readLength(_ length: Int, completionHandler completion: @escaping (Data?, Error?) -> Void) + public func readLength(_ length: Int, completionHandler completion: @escaping (Data?, Error?) -> Void) { readMinimumLength(length, maximumLength: length, completionHandler: completion) } - func write(_ data: Data, completionHandler completion: @escaping (Error?) -> Void) + public func write(_ data: Data, completionHandler completion: @escaping (Error?) -> Void) { guard isViable else @@ -214,12 +214,12 @@ class MeekTCPConnection: TCPConnection } } - func writeClose() + public func writeClose() { network.writeClose() } - func cancel() + public func cancel() { _isViable = false _state = .cancelled @@ -480,7 +480,7 @@ class MeekTCPConnection: TCPConnection } -extension Notification.Name +public extension Notification.Name { static let meekConnectionState = Notification.Name("MeekTCPConnectionState") } diff --git a/Sources/Wisp/WispTCPConnection.swift b/Sources/Wisp/WispTCPConnection.swift index 3dba780..94c5b9e 100644 --- a/Sources/Wisp/WispTCPConnection.swift +++ b/Sources/Wisp/WispTCPConnection.swift @@ -28,7 +28,7 @@ func createWispTCPConnection(connection: TCPConnection, cert: String, iatMode: B return WispTCPConnection(connection: connection, cert: cert, iatMode: iatMode) } -class WispTCPConnection: TCPConnection +public class WispTCPConnection: TCPConnection { var network: TCPConnection var writeClosed = false @@ -50,63 +50,63 @@ class WispTCPConnection: TCPConnection } } - var state: NWTCPConnectionState + public var state: NWTCPConnectionState { get { return _state } } - var isViable: Bool + public var isViable: Bool { get { return _isViable } } - var error: Error? { + public var error: Error? { get { return _error } } - var endpoint: NWEndpoint { + public var endpoint: NWEndpoint { get { return network.endpoint } } - var remoteAddress: NWEndpoint? { + public var remoteAddress: NWEndpoint? { get { return network.remoteAddress } } - var localAddress: NWEndpoint? { + public var localAddress: NWEndpoint? { get { return network.localAddress } } - var connectedPath: NWPath? { + public var connectedPath: NWPath? { get { return network.connectedPath } } - var txtRecord: Data? { + public var txtRecord: Data? { get { return network.txtRecord } } - var hasBetterPath: Bool { + public var hasBetterPath: Bool { get { return network.hasBetterPath } } - convenience init?(provider: PacketTunnelProvider, to: NWEndpoint, cert: String, iatMode: Bool) + public convenience init?(provider: PacketTunnelProvider, to: NWEndpoint, cert: String, iatMode: Bool) { guard let connection = provider.createTCPConnectionThroughTunnel(to: to, enableTLS: true, tlsParameters: nil, delegate: nil) else @@ -117,7 +117,7 @@ class WispTCPConnection: TCPConnection self.init(connection: connection, cert: cert, iatMode: iatMode) } - init?(connection: TCPConnection, cert: String, iatMode: Bool) + public init?(connection: TCPConnection, cert: String, iatMode: Bool) { network = connection _isViable = false @@ -152,11 +152,11 @@ class WispTCPConnection: TCPConnection } } - func observeState(_ callback: @escaping (NWTCPConnectionState, Error?) -> Void) { + public func observeState(_ callback: @escaping (NWTCPConnectionState, Error?) -> Void) { self.stateCallback=callback } - func readMinimumLength(_ minimum: Int, maximumLength maximum: Int, completionHandler completion: @escaping (Data?, Error?) -> Void) + public func readMinimumLength(_ minimum: Int, maximumLength maximum: Int, completionHandler completion: @escaping (Data?, Error?) -> Void) { wisp.readPackets(minRead: minimum, maxRead: maximum) { @@ -180,12 +180,12 @@ class WispTCPConnection: TCPConnection } } - func readLength(_ length: Int, completionHandler completion: @escaping (Data?, Error?) -> Void) + public func readLength(_ length: Int, completionHandler completion: @escaping (Data?, Error?) -> Void) { readMinimumLength(length, maximumLength: length, completionHandler: completion) } - func write(_ data: Data, completionHandler completion: @escaping (Error?) -> Void) + public func write(_ data: Data, completionHandler completion: @escaping (Error?) -> Void) { guard let frame = wisp.encoder?.encode(payload: data) else @@ -203,14 +203,14 @@ class WispTCPConnection: TCPConnection } } - func writeClose() + public func writeClose() { _state = .disconnected _isViable = false network.writeClose() } - func cancel() + public func cancel() { _state = .cancelled _isViable = false @@ -218,7 +218,7 @@ class WispTCPConnection: TCPConnection } } -extension Notification.Name +public extension Notification.Name { static let wispConnectionState = Notification.Name("WispTCPConnectionState") }