2018-10-11 07:13:19 +00:00
|
|
|
//
|
|
|
|
// AppConstants.swift
|
|
|
|
// Passepartout
|
|
|
|
//
|
|
|
|
// Created by Davide De Rosa on 9/15/18.
|
|
|
|
// Copyright (c) 2018 Davide De Rosa. All rights reserved.
|
|
|
|
//
|
|
|
|
// https://github.com/keeshux
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
|
|
|
|
class AppConstants {
|
|
|
|
class Domain {
|
|
|
|
static let name = "passepartoutvpn.app"
|
|
|
|
}
|
|
|
|
|
|
|
|
class Store {
|
|
|
|
static let serviceFilename = "ConnectionService.json"
|
|
|
|
|
|
|
|
static let infrastructureCacheDirectory = "Infrastructures"
|
2018-10-22 08:28:53 +00:00
|
|
|
|
|
|
|
static let profileConfigurationsDirectory = "Configurations"
|
2018-10-11 07:13:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class VPN {
|
|
|
|
static func tunnelConfiguration() -> TunnelKitProvider.Configuration {
|
|
|
|
var builder = TunnelKitProvider.ConfigurationBuilder(ca: CryptoContainer(pem: ""))
|
|
|
|
builder.mtu = 1250
|
|
|
|
builder.shouldDebug = true
|
|
|
|
// builder.debugLogFormat = "$Dyyyy-MM-dd HH:mm:ss.SSS$d $L $N.$F:$l - $M"
|
|
|
|
// builder.debugLogFormat = "$DHH:mm:ss$d $N.$F:$l - $M"
|
|
|
|
builder.debugLogFormat = Log.debugFormat
|
|
|
|
builder.debugLogKey = "LastVPNLog"
|
2018-10-21 21:53:20 +00:00
|
|
|
builder.lastErrorKey = "LastVPNError"
|
2018-10-11 07:13:19 +00:00
|
|
|
return builder.build()
|
|
|
|
}
|
|
|
|
|
|
|
|
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"
|
|
|
|
]
|
|
|
|
|
|
|
|
static let connectivityURL = URL(string: connectivityStrings.customRandomElement())!
|
|
|
|
|
|
|
|
static let connectivityTimeout: TimeInterval = 10.0
|
|
|
|
}
|
|
|
|
|
2018-10-11 17:47:04 +00:00
|
|
|
class Web {
|
2018-10-18 12:07:28 +00:00
|
|
|
private static let version = "v2"
|
2018-10-11 17:47:04 +00:00
|
|
|
|
|
|
|
private static let baseURL = Repos.passepartoutAPI.appendingPathComponent("api/\(version)")
|
2018-10-11 07:13:19 +00:00
|
|
|
|
|
|
|
static func url(path: String) -> URL {
|
|
|
|
return baseURL.appendingPathComponent(path)
|
|
|
|
}
|
|
|
|
|
2018-10-11 17:47:04 +00:00
|
|
|
static let timeout: TimeInterval = 3.0
|
2018-10-11 07:13:19 +00:00
|
|
|
|
|
|
|
static let minimumUpdateInterval: TimeInterval = 600.0 // 10 minutes
|
|
|
|
}
|
|
|
|
|
|
|
|
class Log {
|
|
|
|
static let debugFormat = "$DHH:mm:ss$d - $M"
|
|
|
|
|
|
|
|
static var debugSnapshot: () -> String = { TransientStore.shared.service.vpnLog }
|
|
|
|
|
|
|
|
static var debugFilename: String {
|
|
|
|
let fmt = DateFormatter()
|
|
|
|
fmt.dateFormat = "yyyyMMdd-HHmmss"
|
|
|
|
let iso = fmt.string(from: Date())
|
|
|
|
return "debug-\(iso).txt"
|
|
|
|
}
|
|
|
|
|
|
|
|
static let viewerRefreshInterval: TimeInterval = 3.0
|
|
|
|
|
|
|
|
static func configure() {
|
|
|
|
let console = ConsoleDestination()
|
|
|
|
console.useNSLog = true
|
|
|
|
console.minLevel = .verbose
|
|
|
|
SwiftyBeaver.addDestination(console)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class IssueReporter {
|
|
|
|
static let recipient = "issues@\(Domain.name)"
|
|
|
|
|
|
|
|
static let attachmentMIME = "text/plain"
|
|
|
|
}
|
|
|
|
|
|
|
|
class URLs {
|
|
|
|
static let website = URL(string: "https://\(Domain.name)")!
|
|
|
|
|
|
|
|
static let changelog = Repos.passepartout.appendingPathComponent("blob/master/CHANGELOG.md")
|
|
|
|
|
2018-10-17 21:24:58 +00:00
|
|
|
static let subreddit = URL(string: "https://www.reddit.com/r/passepartout")!
|
|
|
|
|
2018-10-23 09:28:24 +00:00
|
|
|
static let twitterIntent = URL(string: "https://twitter.com/intent/tweet?url=https%3A%2F%2Fpassepartoutvpn.app%2F&via=keeshux&text=Passepartout%20is%20an%20user-friendly%2C%20open%20source%20%23OpenVPN%20client%20for%20%23iOS%20and%20%23macOS")!
|
|
|
|
|
2018-10-11 07:13:19 +00:00
|
|
|
static func review(withId id: String) -> URL {
|
|
|
|
return URL(string: "https://itunes.apple.com/app/id\(id)?action=write-review")!
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Repos {
|
|
|
|
private static let githubRoot = URL(string: "https://github.com/keeshux/")!
|
2018-10-11 17:47:04 +00:00
|
|
|
|
|
|
|
private static let githubRawRoot = URL(string: "https://keeshux.github.io/")!
|
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)
|
|
|
|
}
|
|
|
|
|
2018-10-11 07:13:19 +00:00
|
|
|
static let passepartout = github(repo: "passepartout-ios")
|
|
|
|
|
2018-10-11 17:47:04 +00:00
|
|
|
static let passepartoutAPI = githubRaw(repo: "passepartout-api")
|
|
|
|
|
2018-10-11 07:13:19 +00:00
|
|
|
static let tunnelKit = github(repo: "tunnelkit")
|
|
|
|
}
|
|
|
|
|
|
|
|
class Notices {
|
|
|
|
private static let pia = "PIATunnel - Copyright (c) 2018-Present Private Internet Access"
|
|
|
|
|
|
|
|
private static let swiftyBeaver = "SwiftyBeaver - Copyright (c) 2015 Sebastian Kreutzberger"
|
|
|
|
|
2018-10-11 07:47:40 +00:00
|
|
|
private static let progressHUD = "MBProgressHUD - Copyright (c) 2009-2016 Matej Bukovinski"
|
|
|
|
|
2018-10-11 07:13:19 +00:00
|
|
|
private static let openVPN = "© 2002-2018 OpenVPN Inc. - OpenVPN is a registered trademark of OpenVPN Inc."
|
|
|
|
|
|
|
|
private static let openSSL = "This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit. https://www.openssl.org/"
|
|
|
|
|
|
|
|
static let all: [String] = [
|
|
|
|
pia,
|
|
|
|
swiftyBeaver,
|
2018-10-11 07:47:40 +00:00
|
|
|
progressHUD,
|
2018-10-11 07:13:19 +00:00
|
|
|
openVPN,
|
|
|
|
openSSL
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|