Revert "Move VPNProtocolType serialization to Data layer" (#319)
Reverts passepartoutvpn/passepartout-apple#318 `Codable` compliance at the domain layer (`Profile` etc.) makes this change in serialization destructive.
This commit is contained in:
parent
ddf3dc313f
commit
e960943302
|
@ -25,10 +25,11 @@
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public enum VPNProtocolType: CaseIterable, Codable {
|
// IMPORTANT: do NOT change these raw values, as they affect serialization
|
||||||
case openVPN
|
public enum VPNProtocolType: String, CaseIterable, Codable {
|
||||||
|
case openVPN = "ovpn"
|
||||||
|
|
||||||
case wireGuard
|
case wireGuard = "wg"
|
||||||
}
|
}
|
||||||
|
|
||||||
public protocol VPNProtocolProviding {
|
public protocol VPNProtocolProviding {
|
||||||
|
|
|
@ -57,7 +57,7 @@ extension ProviderServer: Identifiable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func id(withName providerName: ProviderName, vpnProtocol: VPNProtocolType, apiId: String) -> String? {
|
public static func id(withName providerName: ProviderName, vpnProtocol: VPNProtocolType, apiId: String) -> String? {
|
||||||
let idSource = [providerName, "\(vpnProtocol)", apiId].joined(separator: ":")
|
let idSource = [providerName, vpnProtocol.rawValue, apiId].joined(separator: ":")
|
||||||
guard let data = idSource.data(using: .utf8) else {
|
guard let data = idSource.data(using: .utf8) else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
//
|
|
||||||
// VPNProtocolType+RawRepresentable.swift
|
|
||||||
// Passepartout
|
|
||||||
//
|
|
||||||
// Created by Davide De Rosa on 7/2/23.
|
|
||||||
// Copyright (c) 2023 Davide De Rosa. All rights reserved.
|
|
||||||
//
|
|
||||||
// https://github.com/passepartoutvpn
|
|
||||||
//
|
|
||||||
// This file is part of Passepartout.
|
|
||||||
//
|
|
||||||
// Passepartout is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// Passepartout is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with Passepartout. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
//
|
|
||||||
|
|
||||||
import Foundation
|
|
||||||
import PassepartoutCore
|
|
||||||
|
|
||||||
extension VPNProtocolType: RawRepresentable {
|
|
||||||
private static let openVPNString = "ovpn"
|
|
||||||
|
|
||||||
private static let wireGuardString = "wg"
|
|
||||||
|
|
||||||
public init?(rawValue: String) {
|
|
||||||
switch rawValue {
|
|
||||||
case Self.openVPNString:
|
|
||||||
self = .openVPN
|
|
||||||
|
|
||||||
case Self.wireGuardString:
|
|
||||||
self = .wireGuard
|
|
||||||
|
|
||||||
default:
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public var rawValue: String {
|
|
||||||
switch self {
|
|
||||||
case .openVPN:
|
|
||||||
return Self.openVPNString
|
|
||||||
|
|
||||||
case .wireGuard:
|
|
||||||
return Self.wireGuardString
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue