-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b2ffbda
commit 69fa660
Showing
4 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// | ||
// V2RayPorts.swift | ||
// IVPN iOS app | ||
// https://github.com/ivpn/ios-app | ||
// | ||
// Created by Juraj Hilje on 2023-09-18. | ||
// Copyright (c) 2023 IVPN Limited. | ||
// | ||
// This file is part of the IVPN iOS app. | ||
// | ||
// The IVPN iOS app 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. | ||
// | ||
// The IVPN iOS app 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 the IVPN iOS app. If not, see <https://www.gnu.org/licenses/>. | ||
// | ||
|
||
import Foundation | ||
|
||
struct V2RayPorts: Codable { | ||
|
||
let id: String | ||
let openvpn: [V2RayPort] | ||
let wireguard: [V2RayPort] | ||
|
||
func save() { | ||
if let encoded = try? JSONEncoder().encode(self) { | ||
UserDefaults.shared.set(encoded, forKey: UserDefaults.Key.v2RayPorts) | ||
} | ||
} | ||
|
||
static func load() -> V2RayPorts? { | ||
if let saved = UserDefaults.shared.object(forKey: UserDefaults.Key.v2RayPorts) as? Data { | ||
if let loaded = try? JSONDecoder().decode(V2RayPorts.self, from: saved) { | ||
return loaded | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
} | ||
|
||
struct V2RayPort: Codable { | ||
let type: String | ||
let port: Int | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters