Fix OpenVPN endpoint view not handling UDP4/TCP4
This commit is contained in:
parent
c7f7dd89a1
commit
4a047ece58
|
@ -141,7 +141,7 @@ extension EndpointView.OpenVPNView {
|
||||||
themeTextPicker(
|
themeTextPicker(
|
||||||
L10n.Global.Strings.protocol,
|
L10n.Global.Strings.protocol,
|
||||||
selection: $selectedSocketType,
|
selection: $selectedSocketType,
|
||||||
values: allSocketTypes,
|
values: availableSocketTypes,
|
||||||
description: \.rawValue
|
description: \.rawValue
|
||||||
)
|
)
|
||||||
themeTextPicker(
|
themeTextPicker(
|
||||||
|
@ -213,7 +213,7 @@ extension EndpointView.OpenVPNView {
|
||||||
selectedPort = customEndpoint.proto.port
|
selectedPort = customEndpoint.proto.port
|
||||||
} else {
|
} else {
|
||||||
isAutomatic = true
|
isAutomatic = true
|
||||||
guard let socketType = allSocketTypes.first else {
|
guard let socketType = availableSocketTypes.first else {
|
||||||
assertionFailure("No socket types, empty remotes?")
|
assertionFailure("No socket types, empty remotes?")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -234,20 +234,26 @@ extension EndpointView.OpenVPNView {
|
||||||
selectedPort = port
|
selectedPort = port
|
||||||
}
|
}
|
||||||
|
|
||||||
private var allSocketTypes: [SocketType] {
|
private var availableSocketTypes: [SocketType] {
|
||||||
guard let remotes = builder.remotes else {
|
guard let remotes = builder.remotes else {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
var allTypes: [SocketType] = []
|
let allTypes: [SocketType] = [
|
||||||
[SocketType.udp, SocketType.tcp].forEach { socketType in
|
SocketType.udp,
|
||||||
|
SocketType.tcp,
|
||||||
|
SocketType.udp4,
|
||||||
|
SocketType.tcp4
|
||||||
|
]
|
||||||
|
var availableTypes: [SocketType] = []
|
||||||
|
allTypes.forEach { socketType in
|
||||||
guard remotes.contains(where: {
|
guard remotes.contains(where: {
|
||||||
$0.proto.socketType == socketType
|
$0.proto.socketType == socketType
|
||||||
}) else {
|
}) else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
allTypes.append(socketType)
|
availableTypes.append(socketType)
|
||||||
}
|
}
|
||||||
return allTypes
|
return availableTypes
|
||||||
}
|
}
|
||||||
|
|
||||||
private func allPorts(forSocketType socketType: SocketType) -> [UInt16] {
|
private func allPorts(forSocketType socketType: SocketType) -> [UInt16] {
|
||||||
|
|
Loading…
Reference in New Issue