From 1602972c8e4cf10d185875b1882fc0701cb41526 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Thu, 11 Oct 2018 19:47:04 +0200 Subject: [PATCH] Replace self-hosted API with static GitHub Pages --- .../Scenes/ServiceViewController.swift | 2 +- Passepartout/Sources/AppConstants.swift | 16 +++++++++++++--- Passepartout/Sources/Services/WebServices.swift | 4 ++-- README.md | 7 ++++--- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Passepartout-iOS/Scenes/ServiceViewController.swift b/Passepartout-iOS/Scenes/ServiceViewController.swift index 825b55c9..85665378 100644 --- a/Passepartout-iOS/Scenes/ServiceViewController.swift +++ b/Passepartout-iOS/Scenes/ServiceViewController.swift @@ -233,7 +233,7 @@ class ServiceViewController: UIViewController, TableModelHost { private func refreshProviderInfrastructure() { let hud = HUD() - let isUpdating = InfrastructureFactory.shared.update(uncheckedProviderProfile.name, notBeforeInterval: AppConstants.Providers.minimumUpdateInterval) { (response, error) in + let isUpdating = InfrastructureFactory.shared.update(uncheckedProviderProfile.name, notBeforeInterval: AppConstants.Web.minimumUpdateInterval) { (response, error) in hud.hide() guard let response = response else { return diff --git a/Passepartout/Sources/AppConstants.swift b/Passepartout/Sources/AppConstants.swift index b370e921..0988eccb 100644 --- a/Passepartout/Sources/AppConstants.swift +++ b/Passepartout/Sources/AppConstants.swift @@ -63,14 +63,16 @@ class AppConstants { static let connectivityTimeout: TimeInterval = 10.0 } - class Providers { - private static let baseURL = URL(string: "https://api.\(Domain.name)/v1/")! + class Web { + private static let version = "v1" + + private static let baseURL = Repos.passepartoutAPI.appendingPathComponent("api/\(version)") static func url(path: String) -> URL { return baseURL.appendingPathComponent(path) } - static let webTimeout: TimeInterval = 3.0 + static let timeout: TimeInterval = 3.0 static let minimumUpdateInterval: TimeInterval = 600.0 // 10 minutes } @@ -115,13 +117,21 @@ class AppConstants { class Repos { private static let githubRoot = URL(string: "https://github.com/keeshux/")! + + private static let githubRawRoot = URL(string: "https://keeshux.github.io/")! private static func github(repo: String) -> URL { return githubRoot.appendingPathComponent(repo) } + private static func githubRaw(repo: String) -> URL { + return githubRawRoot.appendingPathComponent(repo) + } + static let passepartout = github(repo: "passepartout-ios") + static let passepartoutAPI = githubRaw(repo: "passepartout-api") + static let tunnelKit = github(repo: "tunnelkit") } diff --git a/Passepartout/Sources/Services/WebServices.swift b/Passepartout/Sources/Services/WebServices.swift index 043956e2..4c9ddae4 100644 --- a/Passepartout/Sources/Services/WebServices.swift +++ b/Passepartout/Sources/Services/WebServices.swift @@ -73,8 +73,8 @@ class WebServices { } private func get(_ endpoint: Endpoint) -> URLRequest { - let url = AppConstants.Providers.url(path: endpoint.path) - return URLRequest(url: url, cachePolicy: .reloadIgnoringCacheData, timeoutInterval: AppConstants.Providers.webTimeout) + let url = AppConstants.Web.url(path: endpoint.path) + return URLRequest(url: url, cachePolicy: .reloadIgnoringCacheData, timeoutInterval: AppConstants.Web.timeout) } private func parse(_ type: T.Type, request: URLRequest, completionHandler: @escaping (Response?, Error?) -> Void) { diff --git a/README.md b/README.md index 8aaa01be..34769508 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,13 @@ Keeping the VPN active in the background provides smoother operation, but may be ### No unrequested activity -Passepartout is a VPN client and does absolutely nothing else without your consent. The providers infrastructures are obtained via web services only and only if you manually refresh them. +Passepartout is a VPN client and does absolutely nothing else without your consent. The providers infrastructures are obtained via a [static GitHub API][app-api] only and only if you manually refresh them. ### Presets for major providers Passepartout can connect to a few well-known VPN providers with an existing account: -- [Private Internet Access][net-pia] +- [Private Internet Access][app-net-pia] - ...more soon! In preset mode, you can pick pre-resolved IPv4 endpoints when DNS is problematic. @@ -150,7 +150,8 @@ Bitcoin address: [16w2AWamiH2SS68NYSMDcrbh5MnZ1c5eju][about-btc] [openvpn]: https://openvpn.net/index.php/open-source/overview.html -[net-pia]: https://www.privateinternetaccess.com +[app-api]: https://github.com/keeshux/passepartout-api +[app-net-pia]: https://www.privateinternetaccess.com [snap-home]: res/snap-home.png [snap-profile]: res/snap-profile.png