From 25d84f6530fd7f271250ec0622437d5b1acebefa Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Wed, 24 Oct 2018 18:05:42 +0200 Subject: [PATCH] Add internal flag for masking private data Hardcoded to true. Private data is mostly hostname/IP addresses and routing information. --- TunnelKit/Sources/Core/CoreConfiguration.swift | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/TunnelKit/Sources/Core/CoreConfiguration.swift b/TunnelKit/Sources/Core/CoreConfiguration.swift index 068afcf..c8f12a8 100644 --- a/TunnelKit/Sources/Core/CoreConfiguration.swift +++ b/TunnelKit/Sources/Core/CoreConfiguration.swift @@ -36,6 +36,7 @@ import Foundation import __TunnelKitNative +import CommonCrypto struct CoreConfiguration { static let identifier = "com.algoritmico.TunnelKit" @@ -59,6 +60,8 @@ struct CoreConfiguration { static let logsSensitiveData = false + static let masksPrivateData = true + static let usesReplayProtection = true static let tickInterval = 0.2 @@ -97,3 +100,17 @@ struct CoreConfiguration { static let keysCount = 4 } + +extension CustomStringConvertible { + var maskedDescription: String { + guard CoreConfiguration.masksPrivateData else { + return description + } + var data = description.data(using: .utf8)! + var md = Data(count: Int(CC_SHA1_DIGEST_LENGTH)) + md.withUnsafeMutableBytes { + _ = CC_SHA1(&data, CC_LONG(data.count), $0) + } + return md.toHex() + } +}