tunnelkit/TunnelKit/Sources/AppExtension/GenericSocket.swift
Davide De Rosa 6208fe8e21 Split GenericSocket and LinkInterface
Keep socket and link logic separated. Allows for setting MTU
specifically for the link.

- UDP: hardcoded 1000
- TCP: ignored (.max)
2018-08-24 12:36:35 +02:00

44 lines
963 B
Swift

//
// GenericSocket.swift
// TunnelKit
//
// Created by Davide De Rosa on 4/16/18.
// Copyright © 2018 London Trust Media. All rights reserved.
//
import Foundation
protocol LinkProducer {
func link(withMTU mtu: Int) -> LinkInterface
}
protocol GenericSocketDelegate: class {
func socketDidTimeout(_ socket: GenericSocket)
func socketShouldChangeProtocol(_ socket: GenericSocket)
func socketDidBecomeActive(_ socket: GenericSocket)
func socket(_ socket: GenericSocket, didShutdownWithFailure failure: Bool)
func socketHasBetterPath(_ socket: GenericSocket)
}
protocol GenericSocket: LinkProducer {
var remoteAddress: String? { get }
var hasBetterPath: Bool { get }
var isShutdown: Bool { get }
var delegate: GenericSocketDelegate? { get set }
func observe(queue: DispatchQueue, activeTimeout: Int)
func unobserve()
func shutdown()
func upgraded() -> GenericSocket?
}