diff --git a/PassepartoutLibrary/Sources/PassepartoutCore/Domain/VPNProtocolType.swift b/PassepartoutLibrary/Sources/PassepartoutCore/Domain/VPNProtocolType.swift index ed77120c..49892658 100644 --- a/PassepartoutLibrary/Sources/PassepartoutCore/Domain/VPNProtocolType.swift +++ b/PassepartoutLibrary/Sources/PassepartoutCore/Domain/VPNProtocolType.swift @@ -25,10 +25,11 @@ import Foundation -public enum VPNProtocolType: CaseIterable, Codable { - case openVPN +// IMPORTANT: do NOT change these raw values, as they affect serialization +public enum VPNProtocolType: String, CaseIterable, Codable { + case openVPN = "ovpn" - case wireGuard + case wireGuard = "wg" } public protocol VPNProtocolProviding { diff --git a/PassepartoutLibrary/Sources/PassepartoutProviders/Extensions/Domain+Identifiable.swift b/PassepartoutLibrary/Sources/PassepartoutProviders/Extensions/Domain+Identifiable.swift index e795795e..534a9e97 100644 --- a/PassepartoutLibrary/Sources/PassepartoutProviders/Extensions/Domain+Identifiable.swift +++ b/PassepartoutLibrary/Sources/PassepartoutProviders/Extensions/Domain+Identifiable.swift @@ -57,7 +57,7 @@ extension ProviderServer: Identifiable { } 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 { return nil } diff --git a/PassepartoutLibrary/Sources/PassepartoutProvidersImpl/Strategies/VPNProtocolType+RawRepresentable.swift b/PassepartoutLibrary/Sources/PassepartoutProvidersImpl/Strategies/VPNProtocolType+RawRepresentable.swift deleted file mode 100644 index 50e04b0c..00000000 --- a/PassepartoutLibrary/Sources/PassepartoutProvidersImpl/Strategies/VPNProtocolType+RawRepresentable.swift +++ /dev/null @@ -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 . -// - -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 - } - } -}