Compare commits
2 Commits
9beb2e423e
...
e04447a140
Author | SHA1 | Date | |
---|---|---|---|
|
e04447a140 | ||
|
5205f75f8d |
BIN
Banner.key
Executable file
BIN
Banner.key
Executable file
Binary file not shown.
@ -8,6 +8,9 @@ struct ContentView: View {
|
||||
@AppStorage("counter")
|
||||
var nextMessageCounter: Int = 0
|
||||
|
||||
@AppStorage("compensate")
|
||||
var isCompensatingDaylightTime: Bool = false
|
||||
|
||||
@State
|
||||
var keyManager = KeyManagement()
|
||||
|
||||
@ -31,6 +34,10 @@ struct ContentView: View {
|
||||
@State
|
||||
private var showHistorySheet = false
|
||||
|
||||
var compensationTime: UInt32 {
|
||||
isCompensatingDaylightTime ? 3600 : 0
|
||||
}
|
||||
|
||||
var isPerformingRequests: Bool {
|
||||
hasActiveRequest ||
|
||||
state == .waitingForResponse
|
||||
@ -109,7 +116,7 @@ struct ContentView: View {
|
||||
.frame(width: geo.size.width, height: geo.size.height)
|
||||
.animation(.easeInOut, value: state.color)
|
||||
.sheet(isPresented: $showKeySheet) {
|
||||
KeyView(keyManager: $keyManager)
|
||||
KeyView(keyManager: $keyManager, isCompensatingDaylightTime: $isCompensatingDaylightTime)
|
||||
}
|
||||
.sheet(isPresented: $showHistorySheet) {
|
||||
HistoryView(manager: history)
|
||||
@ -126,8 +133,9 @@ struct ContentView: View {
|
||||
|
||||
let count = UInt32(nextMessageCounter)
|
||||
let sentTime = Date()
|
||||
// Add time to compensate that the device is using daylight savings time
|
||||
let content = Message.Content(
|
||||
time: sentTime.timestamp,
|
||||
time: sentTime.timestamp + compensationTime,
|
||||
id: count)
|
||||
let message = content.authenticate(using: key)
|
||||
let historyItem = HistoryItem(sent: message, date: sentTime)
|
||||
@ -139,7 +147,6 @@ struct ContentView: View {
|
||||
responseTime = receivedTime
|
||||
state = newState
|
||||
let finishedItem = historyItem.didReceive(response: newState, date: receivedTime, message: message)
|
||||
print("Interval: \(receivedTime.timeIntervalSince(sentTime))", "\(finishedItem.roundTripTime ?? -1)")
|
||||
process(item: finishedItem)
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,9 @@ struct KeyView: View {
|
||||
@Binding
|
||||
var keyManager: KeyManagement
|
||||
|
||||
@Binding
|
||||
var isCompensatingDaylightTime: Bool
|
||||
|
||||
var body: some View {
|
||||
GeometryReader { geo in
|
||||
VStack(alignment: .leading, spacing: 16) {
|
||||
@ -13,6 +16,11 @@ struct KeyView: View {
|
||||
keyManager: $keyManager,
|
||||
type: keyType)
|
||||
}
|
||||
Toggle(isOn: $isCompensatingDaylightTime) {
|
||||
Text("Compensate daylight savings time")
|
||||
}
|
||||
Text("If the remote has daylight savings time wrongly set, then the time validation will fail. Use this option to send messages with adjusted timestamps. Warning: Incorrect use of this option will allow replay attacks.")
|
||||
.font(.caption)
|
||||
}.padding()
|
||||
}
|
||||
}
|
||||
@ -20,6 +28,8 @@ struct KeyView: View {
|
||||
|
||||
struct KeyView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
KeyView(keyManager: .constant(KeyManagement()))
|
||||
KeyView(
|
||||
keyManager: .constant(KeyManagement()),
|
||||
isCompensatingDaylightTime: .constant(true))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user