Debug current interfaces in beta

This commit is contained in:
Davide De Rosa 2019-11-05 15:47:08 +01:00
parent c0e5db1ff0
commit 7b8a40cddc
2 changed files with 38 additions and 2 deletions

View File

@ -28,6 +28,7 @@ import StoreKit
import MessageUI import MessageUI
import PassepartoutCore import PassepartoutCore
import Convenience import Convenience
import SystemConfiguration.CaptiveNetwork
// XXX: convoluted due to the separation of provider/host profiles // XXX: convoluted due to the separation of provider/host profiles
@ -80,7 +81,7 @@ class OrganizerViewController: UITableViewController, StrongTableHost {
if AppConstants.Flags.isBeta { if AppConstants.Flags.isBeta {
model.add(.test) model.add(.test)
model.setHeader("Beta", forSection: .test) model.setHeader("Beta", forSection: .test)
model.set([.testDisplayLog, .testTermination], forSection: .test) model.set([.testInterfaces, .testDisplayLog, .testTermination], forSection: .test)
} }
// //
@ -346,6 +347,31 @@ class OrganizerViewController: UITableViewController, StrongTableHost {
// //
private func testInterfaces() {
let alert = UIAlertController.asAlert("Test interfaces", nil)
alert.addCancelAction(L10n.Core.Global.ok)
defer {
present(alert, animated: true, completion: nil)
}
guard let interfaceNames = CNCopySupportedInterfaces() as? [CFString] else {
alert.message = "Nil result from CNCopySupportedInterfaces()"
return
}
var message = interfaceNames.description
message += "\n\n"
for name in interfaceNames {
message += name as String
message += "\n"
guard let iface = CNCopyCurrentNetworkInfo(name) else {
continue
}
message += (iface as NSDictionary).description
message += "\n"
}
alert.message = message
}
private func testDisplayLog() { private func testDisplayLog() {
guard let log = try? String(contentsOf: AppConstants.Log.fileURL) else { guard let log = try? String(contentsOf: AppConstants.Log.fileURL) else {
return return
@ -421,6 +447,8 @@ extension OrganizerViewController {
case uninstall case uninstall
case testInterfaces
case testDisplayLog case testDisplayLog
case testTermination case testTermination
@ -521,6 +549,11 @@ extension OrganizerViewController {
cell.caption = L10n.Core.Organizer.Cells.Uninstall.caption cell.caption = L10n.Core.Organizer.Cells.Uninstall.caption
return cell return cell
case .testInterfaces:
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
cell.leftText = "Show interfaces"
return cell
case .testDisplayLog: case .testDisplayLog:
let cell = Cells.setting.dequeue(from: tableView, for: indexPath) let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
cell.leftText = "Display current log" cell.leftText = "Display current log"
@ -574,6 +607,9 @@ extension OrganizerViewController {
case .uninstall: case .uninstall:
confirmVpnProfileDeletion() confirmVpnProfileDeletion()
case .testInterfaces:
testInterfaces()
case .testDisplayLog: case .testDisplayLog:
testDisplayLog() testDisplayLog()

@ -1 +1 @@
Subproject commit a6f33824ce1434a0fa5bbd49f9d817a776f7ea7b Subproject commit 69d335042a40f55d762bb75ea22fc3a245ef93cd