Extend description of link remote with protocol
This commit is contained in:
parent
f17bb110c2
commit
36f0b2c03d
|
@ -38,13 +38,16 @@ import Foundation
|
|||
|
||||
/// Represents a specific I/O interface meant to work at the link layer (e.g. TCP/IP).
|
||||
public protocol LinkInterface: IOInterface {
|
||||
|
||||
|
||||
/// When `true`, packets delivery is guaranteed.
|
||||
var isReliable: Bool { get }
|
||||
|
||||
/// The literal address of the remote host.
|
||||
var remoteAddress: String? { get }
|
||||
|
||||
/// A literal describing the remote protocol.
|
||||
var remoteProtocol: String? { get }
|
||||
|
||||
/// The number of packets that this interface is able to bufferize.
|
||||
var packetBufferSize: Int { get }
|
||||
|
||||
|
|
|
@ -47,9 +47,16 @@ class NETCPLink: LinkInterface {
|
|||
let isReliable: Bool = true
|
||||
|
||||
var remoteAddress: String? {
|
||||
return (impl.remoteAddress as? NWHostEndpoint)?.hostname
|
||||
(impl.remoteAddress as? NWHostEndpoint)?.hostname
|
||||
}
|
||||
|
||||
var remoteProtocol: String? {
|
||||
guard let remote = impl.remoteAddress as? NWHostEndpoint else {
|
||||
return nil
|
||||
}
|
||||
return "TCP:\(remote.port)"
|
||||
}
|
||||
|
||||
var packetBufferSize: Int {
|
||||
return maxPacketSize
|
||||
}
|
||||
|
|
|
@ -46,9 +46,16 @@ class NEUDPLink: LinkInterface {
|
|||
let isReliable: Bool = false
|
||||
|
||||
var remoteAddress: String? {
|
||||
return (impl.resolvedEndpoint as? NWHostEndpoint)?.hostname
|
||||
(impl.resolvedEndpoint as? NWHostEndpoint)?.hostname
|
||||
}
|
||||
|
||||
var remoteProtocol: String? {
|
||||
guard let remote = impl.resolvedEndpoint as? NWHostEndpoint else {
|
||||
return nil
|
||||
}
|
||||
return "UDP:\(remote.port)"
|
||||
}
|
||||
|
||||
var packetBufferSize: Int {
|
||||
return maxDatagrams
|
||||
}
|
||||
|
|
|
@ -480,11 +480,14 @@ extension OpenVPNTunnelProvider: OpenVPNSessionDelegate {
|
|||
|
||||
// MARK: OpenVPNSessionDelegate (tunnel queue)
|
||||
|
||||
public func sessionDidStart(_ session: OpenVPNSession, remoteAddress: String, options: OpenVPN.Configuration) {
|
||||
public func sessionDidStart(_ session: OpenVPNSession, remoteAddress: String, remoteProtocol: String?, options: OpenVPN.Configuration) {
|
||||
log.info("Session did start")
|
||||
|
||||
log.info("\tAddress: \(remoteAddress.maskedDescription)")
|
||||
if let proto = remoteProtocol {
|
||||
log.info("\tProtocol: \(proto)")
|
||||
}
|
||||
|
||||
log.info("Returned ifconfig parameters:")
|
||||
log.info("\tRemote: \(remoteAddress.maskedDescription)")
|
||||
log.info("\tIPv4: \(options.ipv4?.description ?? "not configured")")
|
||||
log.info("\tIPv6: \(options.ipv6?.description ?? "not configured")")
|
||||
if let routingPolicies = options.routingPolicies {
|
||||
|
|
|
@ -50,9 +50,10 @@ public protocol OpenVPNSessionDelegate: AnyObject {
|
|||
Called after starting a session.
|
||||
|
||||
- Parameter remoteAddress: The address of the VPN server.
|
||||
- Parameter remoteProtocol: The protocol of the VPN server, if specified.
|
||||
- Parameter options: The pulled tunnel settings.
|
||||
*/
|
||||
func sessionDidStart(_: OpenVPNSession, remoteAddress: String, options: OpenVPN.Configuration)
|
||||
func sessionDidStart(_: OpenVPNSession, remoteAddress: String, remoteProtocol: String?, options: OpenVPN.Configuration)
|
||||
|
||||
/**
|
||||
Called after stopping a session.
|
||||
|
@ -981,7 +982,12 @@ public class OpenVPNSession: Session {
|
|||
guard let remoteAddress = link?.remoteAddress else {
|
||||
fatalError("Could not resolve link remote address")
|
||||
}
|
||||
delegate?.sessionDidStart(self, remoteAddress: remoteAddress, options: reply.options)
|
||||
delegate?.sessionDidStart(
|
||||
self,
|
||||
remoteAddress: remoteAddress,
|
||||
remoteProtocol: link?.remoteProtocol,
|
||||
options: reply.options
|
||||
)
|
||||
|
||||
scheduleNextPing()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue