From d605613c62473df1acd744277a6e7f9786aa05e0 Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Thu, 31 Jan 2019 18:17:46 +0530 Subject: [PATCH] Fix handling of 'PersistentKeepalive: every n seconds' --- WireGuard/WireGuard/Base.lproj/Localizable.strings | 2 +- WireGuard/WireGuard/UI/TunnelViewModel.swift | 2 +- .../ViewController/TunnelDetailTableViewController.swift | 6 +++++- .../ViewController/TunnelDetailTableViewController.swift | 6 +++++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/WireGuard/WireGuard/Base.lproj/Localizable.strings b/WireGuard/WireGuard/Base.lproj/Localizable.strings index 328861f..decce3a 100644 --- a/WireGuard/WireGuard/Base.lproj/Localizable.strings +++ b/WireGuard/WireGuard/Base.lproj/Localizable.strings @@ -93,7 +93,7 @@ "tunnelEditPlaceholderTextStronglyRecommended" = "Strongly recommended"; "tunnelEditPlaceholderTextOff" = "Off"; -"tunnelPeerPersistentKeepaliveValue (%d)" = "every %d seconds"; +"tunnelPeerPersistentKeepaliveValue (%@)" = "every %@ seconds"; "tunnelHandshakeTimestampNow" = "Now"; "tunnelHandshakeTimestampSystemClockBackward" = "(System clock is backward)"; "tunnelHandshakeTimestampAgo (%@)" = "%@ ago"; diff --git a/WireGuard/WireGuard/UI/TunnelViewModel.swift b/WireGuard/WireGuard/UI/TunnelViewModel.swift index 5fbe20d..886703e 100644 --- a/WireGuard/WireGuard/UI/TunnelViewModel.swift +++ b/WireGuard/WireGuard/UI/TunnelViewModel.swift @@ -252,7 +252,7 @@ class TunnelViewModel { scratchpad[.endpoint] = endpoint.stringRepresentation } if let persistentKeepAlive = config.persistentKeepAlive { - scratchpad[.persistentKeepAlive] = tr(format: "tunnelPeerPersistentKeepaliveValue (%d)", persistentKeepAlive) + scratchpad[.persistentKeepAlive] = String(persistentKeepAlive) } if let rxBytes = config.rxBytes { scratchpad[.rxBytes] = prettyBytes(rxBytes) diff --git a/WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift b/WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift index 867eda7..f1639f5 100644 --- a/WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift @@ -211,7 +211,11 @@ extension TunnelDetailTableViewController { let field = peerData.filterFieldsWithValueOrControl(peerFields: peerFields)[indexPath.row] let cell: KeyValueCell = tableView.dequeueReusableCell(for: indexPath) cell.key = field.localizedUIString - cell.value = peerData[field] + if field == .persistentKeepAlive { + cell.value = tr(format: "tunnelPeerPersistentKeepaliveValue (%@)", peerData[field]) + } else { + cell.value = peerData[field] + } return cell } diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelDetailTableViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelDetailTableViewController.swift index c9cb09a..9e80009 100644 --- a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelDetailTableViewController.swift +++ b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelDetailTableViewController.swift @@ -286,7 +286,11 @@ extension TunnelDetailTableViewController: NSTableViewDelegate { let cell: KeyValueRow = tableView.dequeueReusableCell() let localizedKeyString = modelRow.isTitleRow() ? modelRow.localizedSectionKeyString() : field.localizedUIString cell.key = tr(format: "macFieldKey (%@)", localizedKeyString) - cell.value = peerData[field] + if field == .persistentKeepAlive { + cell.value = tr(format: "tunnelPeerPersistentKeepaliveValue (%@)", peerData[field]) + } else { + cell.value = peerData[field] + } cell.isKeyInBold = modelRow.isTitleRow() return cell case .spacerRow: