Schedule ping block even just for timeout check
In case keepAliveInterval is not set.
This commit is contained in:
parent
e6f2f3e85a
commit
88a1bdac06
@ -53,6 +53,8 @@ extension CoreConfiguration {
|
||||
|
||||
static let pushRequestInterval = 2.0
|
||||
|
||||
static let pingTimeoutCheckInterval = 10.0
|
||||
|
||||
static let pingTimeout = 120.0
|
||||
|
||||
static let retransmissionLimit = 0.1
|
||||
|
@ -555,19 +555,26 @@ public class OpenVPNSession: Session {
|
||||
return
|
||||
}
|
||||
|
||||
log.debug("Send ping")
|
||||
sendDataPackets([OpenVPN.DataPacket.pingString])
|
||||
lastPing.outbound = Date()
|
||||
// is keep-alive enabled?
|
||||
if let _ = keepAliveInterval {
|
||||
log.debug("Send ping")
|
||||
sendDataPackets([OpenVPN.DataPacket.pingString])
|
||||
lastPing.outbound = Date()
|
||||
}
|
||||
|
||||
// schedule even just to check for ping timeout
|
||||
scheduleNextPing()
|
||||
}
|
||||
|
||||
private func scheduleNextPing() {
|
||||
guard let interval = keepAliveInterval else {
|
||||
log.verbose("Skip ping, keep-alive not set")
|
||||
return
|
||||
let interval: TimeInterval
|
||||
if let keepAliveInterval = keepAliveInterval {
|
||||
interval = keepAliveInterval
|
||||
log.verbose("Schedule ping after \(interval) seconds")
|
||||
} else {
|
||||
interval = CoreConfiguration.OpenVPN.pingTimeoutCheckInterval
|
||||
log.verbose("Schedule ping timeout check after \(interval) seconds")
|
||||
}
|
||||
log.verbose("Schedule ping after \(interval) seconds")
|
||||
queue.asyncAfter(deadline: .now() + interval) { [weak self] in
|
||||
log.verbose("Running ping block")
|
||||
self?.ping()
|
||||
|
Loading…
Reference in New Issue
Block a user