2018-10-11 07:13:19 +00:00
|
|
|
//
|
|
|
|
// AppConstants.swift
|
|
|
|
// Passepartout
|
|
|
|
//
|
|
|
|
// Created by Davide De Rosa on 9/15/18.
|
2019-03-09 10:44:44 +00:00
|
|
|
// Copyright (c) 2019 Davide De Rosa. All rights reserved.
|
2018-10-11 07:13:19 +00:00
|
|
|
//
|
2018-11-03 21:33:30 +00:00
|
|
|
// https://github.com/passepartoutvpn
|
2018-10-11 07:13:19 +00:00
|
|
|
//
|
|
|
|
// 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 TunnelKit
|
|
|
|
import SwiftyBeaver
|
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public class AppConstants {
|
|
|
|
public class Flags {
|
|
|
|
public static let isBeta = false
|
2019-03-06 16:44:27 +00:00
|
|
|
}
|
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public class Domain {
|
|
|
|
public static let name = "passepartoutvpn.app"
|
2018-10-11 07:13:19 +00:00
|
|
|
}
|
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public class Store {
|
|
|
|
public static let serviceFilename = "ConnectionService.json"
|
2018-10-11 07:13:19 +00:00
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public static let webCacheDirectory = "Web"
|
2018-10-22 08:28:53 +00:00
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public static let providersDirectory = "Providers"
|
2018-10-25 19:51:00 +00:00
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public static let hostsDirectory = "Hosts"
|
2018-10-11 07:13:19 +00:00
|
|
|
}
|
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public class Web {
|
2018-12-09 11:11:53 +00:00
|
|
|
private static let version = "v1"
|
2018-10-11 17:47:04 +00:00
|
|
|
|
2018-12-09 11:11:53 +00:00
|
|
|
private static let baseURL = Repos.api.appendingPathComponent(version)
|
2018-10-11 07:13:19 +00:00
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public static func url(path: String) -> URL {
|
2018-10-11 07:13:19 +00:00
|
|
|
return baseURL.appendingPathComponent(path)
|
|
|
|
}
|
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public static let timeout: TimeInterval = 3.0
|
2018-10-11 07:13:19 +00:00
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public static let minimumUpdateInterval: TimeInterval = 600.0 // 10 minutes
|
2019-03-22 18:09:13 +00:00
|
|
|
|
|
|
|
private static let connectivityStrings: [String] = [
|
|
|
|
"https://www.amazon.com",
|
|
|
|
"https://www.google.com",
|
|
|
|
"https://www.twitter.com",
|
|
|
|
"https://www.facebook.com",
|
|
|
|
"https://www.instagram.com"
|
|
|
|
]
|
|
|
|
|
|
|
|
public static let connectivityURL = URL(string: connectivityStrings.customRandomElement())!
|
|
|
|
|
|
|
|
public static let connectivityTimeout: TimeInterval = 10.0
|
2018-10-11 07:13:19 +00:00
|
|
|
}
|
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public class Log {
|
|
|
|
public static let level: SwiftyBeaver.Level = .debug
|
2019-03-07 21:51:01 +00:00
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public static let debugFormat = "$DHH:mm:ss$d - $M"
|
2018-10-11 07:13:19 +00:00
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public static var debugSnapshot: () -> String = { TransientStore.shared.service.vpnLog }
|
2018-10-11 07:13:19 +00:00
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public static let viewerRefreshInterval: TimeInterval = 3.0
|
2019-03-07 21:51:01 +00:00
|
|
|
|
|
|
|
private static let fileName = "Debug.log"
|
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public static var fileURL: URL {
|
2019-03-10 13:44:36 +00:00
|
|
|
return GroupConstants.App.cachesURL.appendingPathComponent(fileName)
|
2019-03-07 21:51:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private static let console: ConsoleDestination = {
|
|
|
|
let dest = ConsoleDestination()
|
|
|
|
dest.minLevel = level
|
|
|
|
dest.useNSLog = true
|
|
|
|
return dest
|
|
|
|
}()
|
|
|
|
|
|
|
|
private static let file: FileDestination = {
|
|
|
|
let dest = FileDestination()
|
|
|
|
dest.minLevel = level
|
|
|
|
dest.logFileURL = fileURL
|
2019-03-08 08:39:37 +00:00
|
|
|
_ = dest.deleteLogFile()
|
2019-03-07 21:51:01 +00:00
|
|
|
return dest
|
|
|
|
}()
|
2018-10-11 07:13:19 +00:00
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public static func configure() {
|
2018-10-11 07:13:19 +00:00
|
|
|
SwiftyBeaver.addDestination(console)
|
2019-03-07 21:51:01 +00:00
|
|
|
SwiftyBeaver.addDestination(file)
|
2018-10-11 07:13:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public class IssueReporter {
|
|
|
|
public static let recipient = "issues@\(Domain.name)"
|
2018-10-11 07:13:19 +00:00
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public class Filenames {
|
|
|
|
public static var debugLog: String {
|
2018-10-23 08:25:41 +00:00
|
|
|
let fmt = DateFormatter()
|
|
|
|
fmt.dateFormat = "yyyyMMdd-HHmmss"
|
|
|
|
let iso = fmt.string(from: Date())
|
|
|
|
return "debug-\(iso).txt"
|
|
|
|
}
|
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public static let configuration = "profile.ovpn"
|
|
|
|
// public static let configuration = "profile.ovpn.txt"
|
2018-10-23 08:25:41 +00:00
|
|
|
}
|
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public class MIME {
|
|
|
|
public static let debugLog = "text/plain"
|
2018-10-23 08:25:41 +00:00
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
// public static let configuration = "application/x-openvpn-profile"
|
|
|
|
public static let configuration = "text/plain"
|
2018-10-23 08:25:41 +00:00
|
|
|
}
|
2018-10-11 07:13:19 +00:00
|
|
|
}
|
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public class URLs {
|
|
|
|
public static let website = URL(string: "https://\(Domain.name)")!
|
2018-10-11 07:13:19 +00:00
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public static let faq = website.appendingPathComponent("faq")
|
2019-02-03 21:07:10 +00:00
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public static let disclaimer = website.appendingPathComponent("disclaimer")
|
2018-10-29 20:22:08 +00:00
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public static let privacyPolicy = website.appendingPathComponent("privacy")
|
2018-10-29 19:59:05 +00:00
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public static let changelog = Repos.ios.appendingPathComponent("blob/master/CHANGELOG.md")
|
2018-10-11 07:13:19 +00:00
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public static let subreddit = URL(string: "https://www.reddit.com/r/passepartout")!
|
2018-10-17 21:24:58 +00:00
|
|
|
|
2018-10-23 09:54:31 +00:00
|
|
|
private static let twitterHashtags = ["OpenVPN", "iOS", "macOS"]
|
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public static var twitterIntent: URL {
|
2018-10-23 09:54:31 +00:00
|
|
|
var text = L10n.Share.message
|
|
|
|
for ht in twitterHashtags {
|
|
|
|
text = text.replacingOccurrences(of: ht, with: "#\(ht)")
|
|
|
|
}
|
|
|
|
var comps = URLComponents(string: "https://twitter.com/intent/tweet")!
|
|
|
|
comps.queryItems = [
|
|
|
|
URLQueryItem(name: "url", value: website.absoluteString),
|
|
|
|
URLQueryItem(name: "via", value: "keeshux"),
|
|
|
|
URLQueryItem(name: "text", value: text)
|
|
|
|
]
|
|
|
|
return comps.url!
|
|
|
|
}
|
2018-10-23 09:28:24 +00:00
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public static func review(withId id: String) -> URL {
|
2018-10-11 07:13:19 +00:00
|
|
|
return URL(string: "https://itunes.apple.com/app/id\(id)?action=write-review")!
|
|
|
|
}
|
2019-03-03 13:11:12 +00:00
|
|
|
|
2019-03-25 21:51:16 +00:00
|
|
|
public static let guidances: [Infrastructure.Name: String] = [
|
2019-03-24 22:08:38 +00:00
|
|
|
.protonVpn: "https://account.protonvpn.com/settings",
|
2019-03-25 21:51:16 +00:00
|
|
|
.windscribe: "https://windscribe.com/getconfig/openvpn"
|
|
|
|
]
|
2019-03-24 23:03:24 +00:00
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public static let referrals: [Infrastructure.Name: String] = [
|
2019-03-24 23:03:24 +00:00
|
|
|
.mullvad: "https://mullvad.net/en/account/create/",
|
2019-03-07 20:37:04 +00:00
|
|
|
.pia: "https://www.privateinternetaccess.com/pages/buy-vpn/",
|
2019-03-24 22:08:38 +00:00
|
|
|
.protonVpn: "https://protonvpn.net/?aid=keeshux",
|
2019-03-22 18:47:59 +00:00
|
|
|
.tunnelBear: "https://click.tunnelbear.com/aff_c?offer_id=2&aff_id=7464",
|
2019-04-01 08:46:39 +00:00
|
|
|
.windscribe: "https://secure.link/kCsD0prd"
|
2019-03-03 13:11:12 +00:00
|
|
|
]
|
2018-10-11 07:13:19 +00:00
|
|
|
}
|
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public class Repos {
|
2018-11-03 21:31:59 +00:00
|
|
|
private static let githubRoot = URL(string: "https://github.com/passepartoutvpn/")!
|
2018-10-11 17:47:04 +00:00
|
|
|
|
2018-12-06 09:25:05 +00:00
|
|
|
private static let githubRawRoot = URL(string: "https://\(Domain.name)/")!
|
2018-10-11 07:13:19 +00:00
|
|
|
|
|
|
|
private static func github(repo: String) -> URL {
|
|
|
|
return githubRoot.appendingPathComponent(repo)
|
|
|
|
}
|
|
|
|
|
2018-10-11 17:47:04 +00:00
|
|
|
private static func githubRaw(repo: String) -> URL {
|
|
|
|
return githubRawRoot.appendingPathComponent(repo)
|
|
|
|
}
|
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public static let ios = github(repo: "passepartout-ios")
|
2018-10-11 07:13:19 +00:00
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public static let api = githubRaw(repo: "api")
|
2018-10-11 07:13:19 +00:00
|
|
|
}
|
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public struct License {
|
|
|
|
public let name: String
|
2018-10-11 07:13:19 +00:00
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public let type: String
|
2018-10-11 07:13:19 +00:00
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public let url: URL
|
2018-12-04 09:41:33 +00:00
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public init(_ name: String, _ type: String, _ urlString: String) {
|
2018-11-26 15:27:15 +00:00
|
|
|
self.name = name
|
|
|
|
self.type = type
|
|
|
|
url = URL(string: urlString)!
|
|
|
|
}
|
2018-10-11 07:13:19 +00:00
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public static let all: [License] = [
|
2018-11-26 15:27:15 +00:00
|
|
|
License(
|
|
|
|
"MBProgressHUD",
|
|
|
|
"MIT",
|
|
|
|
"https://raw.githubusercontent.com/jdg/MBProgressHUD/master/LICENSE"
|
|
|
|
),
|
|
|
|
License(
|
|
|
|
"OpenSSL",
|
|
|
|
"OpenSSL",
|
|
|
|
"https://www.openssl.org/source/license.txt"
|
|
|
|
),
|
|
|
|
License(
|
|
|
|
"PIATunnel",
|
|
|
|
"MIT",
|
|
|
|
"https://raw.githubusercontent.com/pia-foss/tunnel-apple/master/LICENSE"
|
|
|
|
),
|
|
|
|
License(
|
|
|
|
"SwiftGen",
|
|
|
|
"MIT",
|
2019-02-28 16:30:41 +00:00
|
|
|
"https://raw.githubusercontent.com/SwiftGen/SwiftGen/master/LICENCE"
|
2018-11-26 15:27:15 +00:00
|
|
|
),
|
|
|
|
License(
|
|
|
|
"SwiftyBeaver",
|
|
|
|
"MIT",
|
|
|
|
"https://raw.githubusercontent.com/SwiftyBeaver/SwiftyBeaver/master/LICENSE"
|
2019-03-19 12:12:06 +00:00
|
|
|
),
|
|
|
|
License(
|
|
|
|
"lzo",
|
|
|
|
"GPLv2",
|
|
|
|
"https://www.gnu.org/licenses/gpl-2.0.txt"
|
2018-11-26 15:27:15 +00:00
|
|
|
)
|
|
|
|
]
|
2018-12-04 09:41:33 +00:00
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public static var cachedContent: [String: String] = [:]
|
2018-11-26 15:27:15 +00:00
|
|
|
}
|
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public struct Notice {
|
|
|
|
public let name: String
|
2018-11-26 15:27:15 +00:00
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public let statement: String
|
2018-11-26 15:27:15 +00:00
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public init(_ name: String, _ statement: String) {
|
2018-11-26 15:27:15 +00:00
|
|
|
self.name = name
|
|
|
|
self.statement = statement
|
|
|
|
}
|
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public static let all: [Notice] = [
|
2018-11-26 15:27:15 +00:00
|
|
|
Notice(
|
|
|
|
"Circle Icons",
|
|
|
|
"The logo is taken from the awesome Circle Icons set by Nick Roach."
|
|
|
|
),
|
2019-04-05 10:46:50 +00:00
|
|
|
Notice(
|
|
|
|
"Country flags",
|
2019-04-05 11:14:03 +00:00
|
|
|
"The country flags are taken from: https://github.com/lipis/flag-icon-css/"
|
2019-04-05 10:46:50 +00:00
|
|
|
),
|
2018-11-26 15:27:15 +00:00
|
|
|
Notice(
|
|
|
|
"OpenVPN",
|
|
|
|
"© 2002-2018 OpenVPN Inc. - OpenVPN is a registered trademark of OpenVPN Inc."
|
|
|
|
)
|
2018-10-11 07:13:19 +00:00
|
|
|
]
|
|
|
|
}
|
2018-12-10 11:53:01 +00:00
|
|
|
|
2019-03-18 10:29:28 +00:00
|
|
|
public struct Rating {
|
|
|
|
public static let eventCount = 3
|
2018-12-10 11:53:01 +00:00
|
|
|
}
|
2018-10-11 07:13:19 +00:00
|
|
|
}
|