Commit 2a5ecb6e authored by Jose Blaya's avatar Jose Blaya
Browse files

wip

parent 9e3324eb
......@@ -302,6 +302,7 @@
DDD824EA2189CD5700151709 /* NavigationLogoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDD824E92189CD5700151709 /* NavigationLogoView.swift */; };
DDE27E0422E1B1A700503A89 /* ProductTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDE27E0322E1B1A700503A89 /* ProductTests.swift */; };
DDE93C5722F9847E0054FE28 /* PurchaseTrialViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDE93C5622F9847E0054FE28 /* PurchaseTrialViewController.swift */; };
DDF7F73F2405846800A671C7 /* PIAWGTunnelProvider+Profile.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDF7F73E2405846800A671C7 /* PIAWGTunnelProvider+Profile.swift */; };
DDFCFAA821E924A70081F235 /* TileProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDFCFAA721E924A70081F235 /* TileProvider.swift */; };
DDFCFAA921E924AD0081F235 /* TileProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDFCFAA721E924A70081F235 /* TileProvider.swift */; };
DDFCFAAB21E925160081F235 /* DefaultTileProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDFCFAAA21E925160081F235 /* DefaultTileProvider.swift */; };
......@@ -598,6 +599,7 @@
DDD824E92189CD5700151709 /* NavigationLogoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationLogoView.swift; sourceTree = "<group>"; };
DDE27E0322E1B1A700503A89 /* ProductTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ProductTests.swift; path = "../../../../../../System/Volumes/Data/Users/ueshiba/Projects/PIA/client-library-apple/PIALibraryTests/ProductTests.swift"; sourceTree = "<group>"; };
DDE93C5622F9847E0054FE28 /* PurchaseTrialViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PurchaseTrialViewController.swift; sourceTree = "<group>"; };
DDF7F73E2405846800A671C7 /* PIAWGTunnelProvider+Profile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PIAWGTunnelProvider+Profile.swift"; sourceTree = "<group>"; };
DDFCFAA721E924A70081F235 /* TileProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TileProvider.swift; sourceTree = "<group>"; };
DDFCFAAA21E925160081F235 /* DefaultTileProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultTileProvider.swift; sourceTree = "<group>"; };
DDFCFAAC21E925B60081F235 /* TileableCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TileableCell.swift; sourceTree = "<group>"; };
......@@ -1106,6 +1108,7 @@
isa = PBXGroup;
children = (
0EFEB4BF2007784A00F81029 /* PIATunnelProvider+Profile.swift */,
DDF7F73E2405846800A671C7 /* PIAWGTunnelProvider+Profile.swift */,
0EFEB4C02007784A00F81029 /* PIATunnelProfile.swift */,
DD7411A823EC35B40058CEF3 /* PIAWGTunnelProfile.swift */,
);
......@@ -1823,6 +1826,7 @@
DDD824E5218996CD00151709 /* Pages.swift in Sources */,
0E0E5B131F8297DE00022CD0 /* KeychainStore.swift in Sources */,
0E0E5B0D1F8297BD00022CD0 /* PlainStore.swift in Sources */,
DDF7F73F2405846800A671C7 /* PIAWGTunnelProvider+Profile.swift in Sources */,
0EE78AEE1F818720002E4CDD /* LibraryCallback.swift in Sources */,
0E53A8561FE5D770000C2A18 /* MockWebServices.swift in Sources */,
DDC0841322EB07FB00DA2701 /* GlossInvitesInformation.swift in Sources */,
......
......@@ -32,9 +32,12 @@ public enum ServerError: Error {
/// Represents a VPN server.
public class Server: Hashable {
/// Serial host
public let serial: String
/// Represents a VPN server address endpoint.
public struct Address: CustomStringConvertible {
/// The endpoint hostname.
public let hostname: String
......@@ -99,6 +102,7 @@ public class Server: Hashable {
/// :nodoc:
public init(
serial: String,
name: String,
country: String,
hostname: String,
......@@ -106,6 +110,7 @@ public class Server: Hashable {
bestOpenVPNAddressForUDP: Address?,
pingAddress: Address?) {
self.serial = serial
self.name = name
self.country = country
self.hostname = hostname
......
......@@ -27,6 +27,11 @@ class GlossServer: GlossParser {
let parsed: Server
required init?(json: JSON) {
guard let serial: String = "serial" <~~ json else {
return nil
}
guard let name: String = "name" <~~ json else {
return nil
}
......@@ -55,6 +60,7 @@ class GlossServer: GlossParser {
}
parsed = Server(
serial: serial,
name: name,
country: country,
hostname: hostname,
......@@ -69,6 +75,7 @@ class GlossServer: GlossParser {
extension Server: JSONEncodable {
public func toJSON() -> JSON? {
return jsonify([
"serial" ~~> serial,
"name" ~~> name,
"country" ~~> country,
"dns" ~~> hostname,
......
......@@ -28,7 +28,7 @@ import SwiftyBeaver
private let log = SwiftyBeaver.self
class PIAWebServices: WebServices, ConfigurationAccess {
private static let serversVersion = 60
private static let serversVersion = 1001
/***
Generates a new auth token for the specific user
......
......@@ -36,6 +36,7 @@ public class MockServerProvider: ServerProvider, DatabaseAccess, WebServicesCons
public init() {
mockServers = [
Server(
serial: "8a55f03812851897f6e43b2ae22b1234",
name: "France",
country: "fr",
hostname: "france.example.com",
......@@ -43,6 +44,7 @@ public class MockServerProvider: ServerProvider, DatabaseAccess, WebServicesCons
bestOpenVPNAddressForUDP: nil,
pingAddress: nil
), Server(
serial: "8a55f03812851897f6e43b2ae22b1234",
name: "Germany",
country: "de",
hostname: "germany.example.com",
......@@ -50,6 +52,7 @@ public class MockServerProvider: ServerProvider, DatabaseAccess, WebServicesCons
bestOpenVPNAddressForUDP: nil,
pingAddress: nil
), Server(
serial: "8a55f03812851897f6e43b2ae22b1234",
name: "Italy",
country: "it",
hostname: "italy.example.com",
......@@ -57,6 +60,7 @@ public class MockServerProvider: ServerProvider, DatabaseAccess, WebServicesCons
bestOpenVPNAddressForUDP: nil,
pingAddress: nil
), Server(
serial: "8a55f03812851897f6e43b2ae22b1234",
name: "US East",
country: "us",
hostname: "us-east.example.com",
......
......@@ -107,7 +107,7 @@ public class PIAWGTunnelProfile: NetworkExtensionProfile {
/// :nodoc:
public static var vpnType: String {
return "PIA Wireguard"
return "PIAWG"
}
/// :nodoc:
......@@ -227,12 +227,21 @@ public class PIAWGTunnelProfile: NetworkExtensionProfile {
if #available(iOSApplicationExtension 12.0, *) {
//configuration.server
let cfg = NETunnelProviderProtocol()
cfg.providerBundleIdentifier = bundleIdentifier
cfg.serverAddress = "https://blade1.tokyo-rack401.nodes.gen4.ninja"
cfg.serverAddress = configuration.server.hostname
cfg.username = Client.providers.accountProvider.publicUsername
cfg.providerConfiguration = ["token": Client.providers.accountProvider.token]
var customCfg = configuration.customConfiguration
if let piaCfg = customCfg as? PIAWireguardConfiguration {
print(customCfg?.serialized())
}
cfg.providerConfiguration = ["token": Client.providers.accountProvider.token,
"serial": configuration.server.serial] //use serial from server object
return cfg
} else {
......
//
// PIAWGTunnelProvider+Profile.swift
// PIALibrary
//
// Created by Jose Antonio Blaya Garcia on 25/02/2020.
// Copyright © 2020 Private Internet Access, Inc.
//
// This file is part of the Private Internet Access iOS Client.
//
// The Private Internet Access iOS Client 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 Private Internet Access iOS Client 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 Private
// Internet Access iOS Client. If not, see <https://www.gnu.org/licenses/>.
//
import Foundation
import PIAWireguard
extension PIAWireguardConfiguration: VPNCustomConfiguration {
public func serialized() -> [String: Any] {
return ["customDNSServers": customDNSServers]
}
public func isEqual(to: VPNCustomConfiguration) -> Bool {
guard let other = to as? PIAWireguardConfiguration else {
return false
}
guard (customDNSServers == other.customDNSServers) else {
return false
}
return true
}
}
......@@ -9,7 +9,8 @@ PODS:
- PIAWireguard/Core (= 1.0.0)
- PIAWireguard/AppExtension (1.0.0):
- PIAWireguard/Core
- PIAWireguard/Core (1.0.0)
- PIAWireguard/Core (1.0.0):
- Alamofire
- PopupDialog (0.9.2):
- DynamicBlurView (~> 3.0.1)
- QuickLayout (2.0.2)
......@@ -71,7 +72,7 @@ SPEC CHECKSUMS:
Gloss: 13ab6b4b0ff4cb2448466edc957479b1bccea8ba
lottie-ios: 06e0b54aab85ba128e332687d7f4ac4861a7a7ae
OpenSSL-Apple: 2c9efbc94e0a1ada434cc197b02bd70052a82281
PIAWireguard: de9a053e00b729feb13de4b4f59f3fbfa470a4e2
PIAWireguard: 2386a73dd5c658264504b7e1e84cb6bf11795ee4
PopupDialog: f4bb461bf70ff422be0b56656566424ee9273080
QuickLayout: a730730b646b231fd4ef7cffaeb1e81fe0e1ca92
ReachabilitySwift: 408477d1b6ed9779dba301953171e017c31241f3
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment