Skip to content

Commit

Permalink
Sometimes Things Need to be Public >.<
Browse files Browse the repository at this point in the history
  • Loading branch information
consuelita committed May 15, 2018
1 parent 2f3ac7d commit 3f9eb13
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 45 deletions.
52 changes: 26 additions & 26 deletions Sources/Meek/MeekTCPConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,47 +25,47 @@ func createMeekTCPConnection(provider: PacketTunnelProvider, to: URL, serverURL:
return c
}

class MeekTCPConnection: TCPConnection
public class MeekTCPConnection: TCPConnection
{
var hasBetterPath: Bool
public var hasBetterPath: Bool
{
get
{
return network.hasBetterPath
}
}

var endpoint: NWEndpoint
public var endpoint: NWEndpoint
{
get
{
return network.endpoint
}
}

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<UInt32>.size

enum MeekError: Error
public enum MeekError: Error
{
case unknownError
case connectionError
Expand All @@ -79,23 +79,23 @@ class MeekTCPConnection: TCPConnection
case unsuppotedURL
}

var isViable: Bool
public var isViable: Bool
{
get
{
return _isViable
}
}

var state: NWTCPConnectionState
public var state: NWTCPConnectionState
{
get
{
return _state
}
}

var stateCallback: ((NWTCPConnectionState, Error?) -> Void)?
public var stateCallback: ((NWTCPConnectionState, Error?) -> Void)?

private var _isViable: Bool
private var _error: Error?
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -214,12 +214,12 @@ class MeekTCPConnection: TCPConnection
}
}

func writeClose()
public func writeClose()
{
network.writeClose()
}

func cancel()
public func cancel()
{
_isViable = false
_state = .cancelled
Expand Down Expand Up @@ -480,7 +480,7 @@ class MeekTCPConnection: TCPConnection

}

extension Notification.Name
public extension Notification.Name
{
static let meekConnectionState = Notification.Name("MeekTCPConnectionState")
}
38 changes: 19 additions & 19 deletions Sources/Wisp/WispTCPConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
{
Expand All @@ -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
Expand All @@ -203,22 +203,22 @@ class WispTCPConnection: TCPConnection
}
}

func writeClose()
public func writeClose()
{
_state = .disconnected
_isViable = false
network.writeClose()
}

func cancel()
public func cancel()
{
_state = .cancelled
_isViable = false
network.cancel()
}
}

extension Notification.Name
public extension Notification.Name
{
static let wispConnectionState = Notification.Name("WispTCPConnectionState")
}

0 comments on commit 3f9eb13

Please sign in to comment.