Improve logging on ineligible features

This commit is contained in:
Davide 2024-11-05 14:05:17 +01:00
parent 320b92591e
commit 9286ead348
No known key found for this signature in database
GPG Key ID: A48836171C759F5E
3 changed files with 16 additions and 9 deletions

View File

@ -99,6 +99,11 @@ public struct Constants: Decodable, Sendable {
public let refreshInterval: TimeInterval
public let tvExpirationMinutes: Int
public func newTVExpirationDate() -> Date {
Date()
.addingTimeInterval(Double(tvExpirationMinutes) * 60.0)
}
}
public struct API: Decodable, Sendable {

View File

@ -107,14 +107,16 @@ private extension TunnelToggleButton {
}
}
if canConnect && profile.isInteractive {
if iapManager.isEligible(for: .interactiveLogin) {
// ineligible, suppress interactive login
if !iapManager.isEligible(for: .interactiveLogin) {
pp_log(.app, .notice, "Ineligible, suppress interactive login")
} else {
pp_log(.app, .notice, "Present interactive login")
interactiveManager.present(with: profile) {
await perform(with: $0)
}
return
} else {
pp_log(.app, .notice, "Suppress interactive login, not eligible")
}
}
await perform(with: profile)

View File

@ -59,12 +59,12 @@ extension AppContext {
// preprocess TV profiles
if attributes.isAvailableForTV == true {
// if ineligible, set expiration date unless already set
// ineligible, set expiration date unless already set
if !iap.isEligible(for: .appleTV),
attributes.expirationDate == nil || attributes.isExpired {
attributes.expirationDate = Date()
.addingTimeInterval(Double(Constants.shared.tunnel.tvExpirationMinutes) * 60.0)
let expirationDate = Constants.shared.tunnel.newTVExpirationDate()
pp_log(.app, .notice, "Ineligible, apply expiration date: \(expirationDate)")
attributes.expirationDate = expirationDate
} else {
attributes.expirationDate = nil
}
@ -76,9 +76,9 @@ extension AppContext {
willConnect: { iap, profile in
var builder = profile.builder()
// suppress on-demand rules if not eligible
// ineligible, suppress on-demand rules
if !iap.isEligible(for: .onDemand) {
pp_log(.app, .notice, "Suppress on-demand rules, not eligible")
pp_log(.app, .notice, "Ineligible, suppress on-demand rules")
if let onDemandModuleIndex = builder.modules.firstIndex(where: { $0 is OnDemandModule }),
let onDemandModule = builder.modules[onDemandModuleIndex] as? OnDemandModule {