summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadREST/Transport/Shadowsocks/ShadowsocksCacheCleaner.swift
blob: 6431dfd8dfab70cd1abc9f5ca1051a3db0f5123c (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
//
//  ShadowsocksCacheCleaner.swift
//  MullvadREST
//
//  Created by Marco Nikic on 2025-09-18.
//  Copyright © 2025 Mullvad VPN AB. All rights reserved.
//

import Foundation
import MullvadSettings
import MullvadTypes

public class ShadowsocksCacheCleaner: MullvadAccessMethodChangeListening {
    let cache: ShadowsocksConfigurationCacheProtocol
    var lastChangedUUID = UUID(uuidString: "00000000-0000-0000-0000-000000000000")!

    public init(cache: ShadowsocksConfigurationCacheProtocol) {
        self.cache = cache
    }

    public func accessMethodChangedTo(_ uuid: UUID) {
        if lastChangedUUID == AccessMethodRepository.bridgeId {
            try? cache.clear()
        }
        lastChangedUUID = uuid
    }
}