Extend description of link remote with protocol
This commit is contained in:
parent
f17bb110c2
commit
36f0b2c03d
|
@ -45,6 +45,9 @@ public protocol LinkInterface: IOInterface {
|
||||||
/// The literal address of the remote host.
|
/// The literal address of the remote host.
|
||||||
var remoteAddress: String? { get }
|
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.
|
/// The number of packets that this interface is able to bufferize.
|
||||||
var packetBufferSize: Int { get }
|
var packetBufferSize: Int { get }
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,14 @@ class NETCPLink: LinkInterface {
|
||||||
let isReliable: Bool = true
|
let isReliable: Bool = true
|
||||||
|
|
||||||
var remoteAddress: String? {
|
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 {
|
var packetBufferSize: Int {
|
||||||
|
|
|
@ -46,7 +46,14 @@ class NEUDPLink: LinkInterface {
|
||||||
let isReliable: Bool = false
|
let isReliable: Bool = false
|
||||||
|
|
||||||
var remoteAddress: String? {
|
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 {
|
var packetBufferSize: Int {
|
||||||
|
|
|
@ -480,11 +480,14 @@ extension OpenVPNTunnelProvider: OpenVPNSessionDelegate {
|
||||||
|
|
||||||
// MARK: OpenVPNSessionDelegate (tunnel queue)
|
// 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("Session did start")
|
||||||
|
log.info("\tAddress: \(remoteAddress.maskedDescription)")
|
||||||
|
if let proto = remoteProtocol {
|
||||||
|
log.info("\tProtocol: \(proto)")
|
||||||
|
}
|
||||||
|
|
||||||
log.info("Returned ifconfig parameters:")
|
log.info("Returned ifconfig parameters:")
|
||||||
log.info("\tRemote: \(remoteAddress.maskedDescription)")
|
|
||||||
log.info("\tIPv4: \(options.ipv4?.description ?? "not configured")")
|
log.info("\tIPv4: \(options.ipv4?.description ?? "not configured")")
|
||||||
log.info("\tIPv6: \(options.ipv6?.description ?? "not configured")")
|
log.info("\tIPv6: \(options.ipv6?.description ?? "not configured")")
|
||||||
if let routingPolicies = options.routingPolicies {
|
if let routingPolicies = options.routingPolicies {
|
||||||
|
|
|
@ -50,9 +50,10 @@ public protocol OpenVPNSessionDelegate: AnyObject {
|
||||||
Called after starting a session.
|
Called after starting a session.
|
||||||
|
|
||||||
- Parameter remoteAddress: The address of the VPN server.
|
- Parameter remoteAddress: The address of the VPN server.
|
||||||
|
- Parameter remoteProtocol: The protocol of the VPN server, if specified.
|
||||||
- Parameter options: The pulled tunnel settings.
|
- 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.
|
Called after stopping a session.
|
||||||
|
@ -981,7 +982,12 @@ public class OpenVPNSession: Session {
|
||||||
guard let remoteAddress = link?.remoteAddress else {
|
guard let remoteAddress = link?.remoteAddress else {
|
||||||
fatalError("Could not resolve link remote address")
|
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()
|
scheduleNextPing()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue