Use keypath in .map occurrences

This commit is contained in:
Davide De Rosa 2022-10-27 00:31:30 +02:00
parent 5913b801a9
commit fa5aa86399
7 changed files with 11 additions and 11 deletions

View File

@ -75,6 +75,6 @@ public struct IPv4Settings: Codable, Equatable, CustomStringConvertible {
// MARK: CustomStringConvertible // MARK: CustomStringConvertible
public var description: String { public var description: String {
return "addr \(address.maskedDescription) netmask \(addressMask) gw \(defaultGateway.maskedDescription) routes \(routes.map { $0.maskedDescription })" return "addr \(address.maskedDescription) netmask \(addressMask) gw \(defaultGateway.maskedDescription) routes \(routes.map(\.maskedDescription))"
} }
} }

View File

@ -75,6 +75,6 @@ public struct IPv6Settings: Codable, Equatable, CustomStringConvertible {
// MARK: CustomStringConvertible // MARK: CustomStringConvertible
public var description: String { public var description: String {
return "addr \(address.maskedDescription)/\(addressPrefixLength) gw \(defaultGateway.maskedDescription) routes \(routes.map { $0.maskedDescription })" return "addr \(address.maskedDescription)/\(addressPrefixLength) gw \(defaultGateway.maskedDescription) routes \(routes.map(\.maskedDescription))"
} }
} }

View File

@ -674,7 +674,7 @@ extension OpenVPN.Configuration {
log.info("\tRandomize hostnames: true") log.info("\tRandomize hostnames: true")
} }
if let routingPolicies = routingPolicies { if let routingPolicies = routingPolicies {
log.info("\tGateway: \(routingPolicies.map { $0.rawValue })") log.info("\tGateway: \(routingPolicies.map(\.rawValue))")
} else { } else {
log.info("\tGateway: not configured") log.info("\tGateway: not configured")
} }

View File

@ -378,11 +378,11 @@ extension OpenVPN {
optClientKey = CryptoContainer(pem: currentBlock.joined(separator: "\n")) optClientKey = CryptoContainer(pem: currentBlock.joined(separator: "\n"))
case "tls-auth": case "tls-auth":
optTLSKeyLines = currentBlock.map { Substring($0) } optTLSKeyLines = currentBlock.map(Substring.init(_:))
optTLSStrategy = .auth optTLSStrategy = .auth
case "tls-crypt": case "tls-crypt":
optTLSKeyLines = currentBlock.map { Substring($0) } optTLSKeyLines = currentBlock.map(Substring.init(_:))
optTLSStrategy = .crypt optTLSStrategy = .crypt
default: default:

View File

@ -160,7 +160,7 @@ extension OpenVPN {
// peer info // peer info
var extra: [String: String] = [:] var extra: [String: String] = [:]
if let dataCiphers = options.dataCiphers { if let dataCiphers = options.dataCiphers {
extra["IV_CIPHERS"] = dataCiphers.map { $0.rawValue }.joined(separator: ":") extra["IV_CIPHERS"] = dataCiphers.map(\.rawValue).joined(separator: ":")
} }
raw.appendSized(Z(CoreConfiguration.OpenVPN.peerInfo(extra: extra), nullTerminated: true)) raw.appendSized(Z(CoreConfiguration.OpenVPN.peerInfo(extra: extra), nullTerminated: true))

View File

@ -62,7 +62,7 @@ open class WireGuardTunnelProvider: NEPacketTunnelProvider {
completionHandler(WireGuardProviderError.couldNotDetermineFileDescriptor) completionHandler(WireGuardProviderError.couldNotDetermineFileDescriptor)
case .dnsResolution(let dnsErrors): case .dnsResolution(let dnsErrors):
let hostnamesWithDnsResolutionFailure = dnsErrors.map { $0.address } let hostnamesWithDnsResolutionFailure = dnsErrors.map(\.address)
.joined(separator: ", ") .joined(separator: ", ")
wg_log(.error, message: "DNS resolution failed for the following hostnames: \(hostnamesWithDnsResolutionFailure)") wg_log(.error, message: "DNS resolution failed for the following hostnames: \(hostnamesWithDnsResolutionFailure)")
self.cfg._appexSetLastError(.dnsResolutionFailure) self.cfg._appexSetLastError(.dnsResolutionFailure)

View File

@ -112,7 +112,7 @@ extension TunnelConfiguration {
} }
} }
let peerPublicKeysArray = peerConfigurations.map { $0.publicKey } let peerPublicKeysArray = peerConfigurations.map(\.publicKey)
let peerPublicKeysSet = Set<PublicKey>(peerPublicKeysArray) let peerPublicKeysSet = Set<PublicKey>(peerPublicKeysArray)
if peerPublicKeysArray.count != peerPublicKeysSet.count { if peerPublicKeysArray.count != peerPublicKeysSet.count {
throw ParseError.multiplePeersWithSamePublicKey throw ParseError.multiplePeersWithSamePublicKey
@ -132,11 +132,11 @@ extension TunnelConfiguration {
output.append("ListenPort = \(listenPort)\n") output.append("ListenPort = \(listenPort)\n")
} }
if !interface.addresses.isEmpty { if !interface.addresses.isEmpty {
let addressString = interface.addresses.map { $0.stringRepresentation }.joined(separator: ", ") let addressString = interface.addresses.map(\.stringRepresentation).joined(separator: ", ")
output.append("Address = \(addressString)\n") output.append("Address = \(addressString)\n")
} }
if !interface.dns.isEmpty || !interface.dnsSearch.isEmpty { if !interface.dns.isEmpty || !interface.dnsSearch.isEmpty {
var dnsLine = interface.dns.map { $0.stringRepresentation } var dnsLine = interface.dns.map(\.stringRepresentation)
dnsLine.append(contentsOf: interface.dnsSearch) dnsLine.append(contentsOf: interface.dnsSearch)
let dnsString = dnsLine.joined(separator: ", ") let dnsString = dnsLine.joined(separator: ", ")
output.append("DNS = \(dnsString)\n") output.append("DNS = \(dnsString)\n")
@ -152,7 +152,7 @@ extension TunnelConfiguration {
output.append("PresharedKey = \(preSharedKey)\n") output.append("PresharedKey = \(preSharedKey)\n")
} }
if !peer.allowedIPs.isEmpty { if !peer.allowedIPs.isEmpty {
let allowedIPsString = peer.allowedIPs.map { $0.stringRepresentation }.joined(separator: ", ") let allowedIPsString = peer.allowedIPs.map(\.stringRepresentation).joined(separator: ", ")
output.append("AllowedIPs = \(allowedIPsString)\n") output.append("AllowedIPs = \(allowedIPsString)\n")
} }
if let endpoint = peer.endpoint { if let endpoint = peer.endpoint {