summaryrefslogtreecommitdiffhomepage
path: root/ios/Shared/ApplicationConfiguration.swift
blob: 92d362c806bfc9ee62ffef3204310829b855dd11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//
//  ApplicationConfiguration.swift
//  MullvadVPN
//
//  Created by pronebird on 05/06/2019.
//  Copyright © 2019 Mullvad VPN AB. All rights reserved.
//

import Foundation
import struct Network.IPv4Address

class ApplicationConfiguration {
    /// Shared container security group identifier.
    static var securityGroupIdentifier: String {
        let securityGroupIdentifier = Bundle(for: Self.self)
            .object(forInfoDictionaryKey: "ApplicationSecurityGroupIdentifier") as? String
        return securityGroupIdentifier!
    }

    /// The application identifier for packet tunnel extension.
    static var packetTunnelExtensionIdentifier: String {
        let mainBundleIdentifier = Bundle.main.bundleIdentifier!

        return "\(mainBundleIdentifier).PacketTunnel"
    }

    /// Container URL for security group
    static var containerURL: URL? {
        return FileManager.default
            .containerURL(forSecurityApplicationGroupIdentifier: Self.securityGroupIdentifier)
    }

    /// The main application log file located in a shared container
    static var mainApplicationLogFileURL: URL? {
        return Self.containerURL?.appendingPathComponent(
            "Logs/net.mullvad.MullvadVPN.log",
            isDirectory: false
        )
    }

    /// The packet tunnel log file located in a shared container
    static var packetTunnelLogFileURL: URL? {
        return Self.containerURL?.appendingPathComponent(
            "Logs/net.mullvad.MullvadVPN.PacketTunnel.log",
            isDirectory: false
        )
    }

    /// All log files located in a shared container
    static var logFileURLs: [URL] {
        return [mainApplicationLogFileURL, packetTunnelLogFileURL].compactMap { $0 }
    }

    /// Privacy policy URL.
    static let privacyPolicyURL = URL(string: "https://mullvad.net/help/privacy-policy/")!

    /// FAQ & Guides URL.
    static let faqAndGuidesURL = URL(string: "https://mullvad.net/help/tag/mullvad-app/")!

    /// Maximum number of devices per account.
    static let maxAllowedDevices = 5

    /// App refresh background task identifier
    static let appRefreshTaskIdentifier = "net.mullvad.MullvadVPN.AppRefresh"

    /// Key rotation background task identifier
    static let privateKeyRotationTaskIdentifier = "net.mullvad.MullvadVPN.PrivateKeyRotation"

    /// API address background task identifier
    static let addressCacheUpdateTaskIdentifier = "net.mullvad.MullvadVPN.AddressCacheUpdate"

    private init() {}
}