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:
Davide De Rosa 2023-07-03 11:18:12 +02:00 committed by GitHub
parent ddf3dc313f
commit e960943302
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 60 deletions

View File

@ -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 {

View File

@ -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
} }

View File

@ -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
}
}
}