6208fe8e21
Keep socket and link logic separated. Allows for setting MTU specifically for the link. - UDP: hardcoded 1000 - TCP: ignored (.max)
44 lines
963 B
Swift
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?
|
|
}
|