Delete log on masking change

It may contain stale and either sensitive or irrelevant data.
This commit is contained in:
Davide De Rosa 2019-03-21 21:27:24 +01:00
parent 96f5210c7c
commit e4c1ea4def
2 changed files with 31 additions and 4 deletions

View File

@ -48,6 +48,8 @@ class ServiceViewController: UIViewController, TableModelHost {
private var lastInfrastructureUpdate: Date?
private var shouldDeleteLogOnDisconnection = false
// MARK: Table
var model: TableModel<SectionType, RowType> = TableModel()
@ -401,6 +403,14 @@ class ServiceViewController: UIViewController, TableModelHost {
private func togglePrivateDataMasking(cell: ToggleTableViewCell) {
AppConstants.VPN.baseConfiguration.masksPrivateData = cell.isOn
service.baseConfiguration = AppConstants.VPN.baseConfiguration.build()
// for privacy, delete potentially unmasked data
if vpn.status != .disconnected {
shouldDeleteLogOnDisconnection = true
} else {
service.eraseVpnLog()
shouldDeleteLogOnDisconnection = false
}
}
private func postSupportRequest() {
@ -417,8 +427,21 @@ class ServiceViewController: UIViewController, TableModelHost {
@objc private func vpnDidUpdate() {
reloadVpnStatus()
if vpn.status == .connected {
guard let status = vpn.status else {
return
}
switch status {
case .connected:
Reviewer.shared.reportEvent()
case .disconnected:
if shouldDeleteLogOnDisconnection {
service.eraseVpnLog()
shouldDeleteLogOnDisconnection = false
}
default:
break
}
}

View File

@ -510,7 +510,11 @@ public class ConnectionService: Codable {
baseConfiguration.clearLastError(in: appGroup)
}
// public func eraseVpnLog() {
// defaults.removeObject(forKey: Keys.vpnLog)
// }
public func eraseVpnLog() {
log.info("Erasing VPN log...")
guard let url = baseConfiguration.urlForLog(in: appGroup) else {
return
}
try? FileManager.default.removeItem(at: url)
}
}