summaryrefslogtreecommitdiffhomepage
path: root/ios/Shared/ApplicationConfiguration.swift
blob: 9acea1b971355b764e1583ff8dee7abdd88cc809 (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
//
//  ApplicationConfiguration.swift
//  MullvadVPN
//
//  Created by pronebird on 05/06/2019.
//  Copyright © 2019 Mullvad VPN AB. All rights reserved.
//

import Foundation
import Network

enum ApplicationConfiguration {
    /// Shared container security group identifier.
    static var securityGroupIdentifier: String {
        // swiftlint:disable:next force_cast
        Bundle.main.object(forInfoDictionaryKey: "ApplicationSecurityGroupIdentifier") as! String
    }

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

    /// Returns URL for new log file associated with application target and located within shared container.
    static func newLogFileURL(for target: ApplicationTarget) -> URL {
        containerURL.appendingPathComponent(
            "\(target.bundleIdentifier)_\(Date().logFormatFilename()).log",
            isDirectory: false
        )
    }

    /// Returns URLs for log files associated with application target and located within shared container.
    static func logFileURLs(for target: ApplicationTarget) -> [URL] {
        let containerUrl = containerURL

        return (try? FileManager.default.contentsOfDirectory(atPath: containerURL.relativePath))?.compactMap { file in
            if file.split(separator: ".").last == "log" {
                containerUrl.appendingPathComponent(file)
            } else {
                nil
            }
        }.sorted { $0.relativePath > $1.relativePath } ?? []
    }

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

    /// Make a start regarding  policy URL.
    static let privacyGuidesURL = URL(string: "https://mullvad.net/help/first-steps-towards-online-privacy/")!

    /// 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
}