Merge branch 'github-static-api'

This commit is contained in:
Davide De Rosa 2018-10-11 21:31:43 +02:00
commit 3b237e8a3f
4 changed files with 20 additions and 9 deletions

View File

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

View File

@ -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
}
@ -116,12 +118,20 @@ 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")
}

View File

@ -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<T: Decodable>(_ type: T.Type, request: URLRequest, completionHandler: @escaping (Response<T>?, Error?) -> Void) {

View File

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