Improve logging on ineligible features
This commit is contained in:
parent
320b92591e
commit
9286ead348
|
@ -99,6 +99,11 @@ public struct Constants: Decodable, Sendable {
|
||||||
public let refreshInterval: TimeInterval
|
public let refreshInterval: TimeInterval
|
||||||
|
|
||||||
public let tvExpirationMinutes: Int
|
public let tvExpirationMinutes: Int
|
||||||
|
|
||||||
|
public func newTVExpirationDate() -> Date {
|
||||||
|
Date()
|
||||||
|
.addingTimeInterval(Double(tvExpirationMinutes) * 60.0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct API: Decodable, Sendable {
|
public struct API: Decodable, Sendable {
|
||||||
|
|
|
@ -107,14 +107,16 @@ private extension TunnelToggleButton {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if canConnect && profile.isInteractive {
|
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")
|
pp_log(.app, .notice, "Present interactive login")
|
||||||
interactiveManager.present(with: profile) {
|
interactiveManager.present(with: profile) {
|
||||||
await perform(with: $0)
|
await perform(with: $0)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
} else {
|
|
||||||
pp_log(.app, .notice, "Suppress interactive login, not eligible")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await perform(with: profile)
|
await perform(with: profile)
|
||||||
|
|
|
@ -59,12 +59,12 @@ extension AppContext {
|
||||||
// preprocess TV profiles
|
// preprocess TV profiles
|
||||||
if attributes.isAvailableForTV == true {
|
if attributes.isAvailableForTV == true {
|
||||||
|
|
||||||
// if ineligible, set expiration date unless already set
|
// ineligible, set expiration date unless already set
|
||||||
if !iap.isEligible(for: .appleTV),
|
if !iap.isEligible(for: .appleTV),
|
||||||
attributes.expirationDate == nil || attributes.isExpired {
|
attributes.expirationDate == nil || attributes.isExpired {
|
||||||
|
let expirationDate = Constants.shared.tunnel.newTVExpirationDate()
|
||||||
attributes.expirationDate = Date()
|
pp_log(.app, .notice, "Ineligible, apply expiration date: \(expirationDate)")
|
||||||
.addingTimeInterval(Double(Constants.shared.tunnel.tvExpirationMinutes) * 60.0)
|
attributes.expirationDate = expirationDate
|
||||||
} else {
|
} else {
|
||||||
attributes.expirationDate = nil
|
attributes.expirationDate = nil
|
||||||
}
|
}
|
||||||
|
@ -76,9 +76,9 @@ extension AppContext {
|
||||||
willConnect: { iap, profile in
|
willConnect: { iap, profile in
|
||||||
var builder = profile.builder()
|
var builder = profile.builder()
|
||||||
|
|
||||||
// suppress on-demand rules if not eligible
|
// ineligible, suppress on-demand rules
|
||||||
if !iap.isEligible(for: .onDemand) {
|
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 }),
|
if let onDemandModuleIndex = builder.modules.firstIndex(where: { $0 is OnDemandModule }),
|
||||||
let onDemandModule = builder.modules[onDemandModuleIndex] as? OnDemandModule {
|
let onDemandModule = builder.modules[onDemandModuleIndex] as? OnDemandModule {
|
||||||
|
|
Loading…
Reference in New Issue