@@ -278,6 +278,13 @@ Swift: @code func onInternetReachabilityChanged(_ currentReachability: Reachabil
*/
- (void)onHomepage:(NSString * _Nonnull)url;
+/*!
+ Called when tunnel-core receives server timetamp in the handshake
+ @param timestamp The server timestamp in RFC3339 format.
+ Swift: @code func onServerTimestamp(_ timestamp: String) @endcode
+ */
+- (void)onServerTimestamp:(NSString * _Nonnull)timestamp;
+
@end
/*!
@@ -763,6 +763,19 @@
});
}
+ else if ([noticeType isEqualToString:@"ServerTimestamp"]) {
+ id timestamp = [notice valueForKeyPath:@"data.timestamp"];
+ if (![timestamp isKindOfClass:[NSString class]]) {
+ [self logMessage:[NSString stringWithFormat: @"ServerTimestamp notice missing data.timestamp: %@", noticeJSON]];
+ return;
+ }
+ if ([self.tunneledAppDelegate respondsToSelector:@selector(onServerTimestamp:)]) {
+ dispatch_async(self->callbackQueue, ^{
+ [self.tunneledAppDelegate onServerTimestamp:timestamp];
+ });
// Pass diagnostic messages to onDiagnosticMessage.
if (diagnostic) {
@@ -416,6 +416,11 @@ func NoticeSLOKSeeded(slokID string, duplicate bool) {
outputNotice("SLOKSeeded", noticeIsDiagnostic, "slokID", slokID, "duplicate", duplicate)
+// NoticeServerTimestamp reports server side timestamp as seen in the handshake
+func NoticeServerTimestamp(timestamp string) {
+ outputNotice("ServerTimestamp", 0, "timestamp", timestamp)
+}
type repetitiveNoticeState struct {
message string
repeats int
@@ -244,6 +244,7 @@ func (serverContext *ServerContext) doHandshakeRequest(
serverContext.serverHandshakeTimestamp = handshakeResponse.ServerTimestamp
+ NoticeServerTimestamp(serverContext.serverHandshakeTimestamp)
return nil