Compare commits
15 Commits
755908a189
...
525bb67529
Author | SHA1 | Date |
---|---|---|
Ian VanSchooten | 525bb67529 | |
Ian VanSchooten | 1c32d11503 | |
Ian VanSchooten | 4374c9d5b6 | |
Ian VanSchooten | 571093410e | |
Ian VanSchooten | daa634fdb3 | |
Ian VanSchooten | 4c6d9d0745 | |
Ian VanSchooten | dfa0e7bd40 | |
Ian VanSchooten | 5ba3891eda | |
Ian VanSchooten | 093d734094 | |
Ian VanSchooten | cb8b44bd27 | |
Ian VanSchooten | d26b25704d | |
Ian VanSchooten | ed9aeff3e0 | |
Ian VanSchooten | 9f262ba5a7 | |
Ian VanSchooten | 22a13b1a1c | |
Ian VanSchooten | b2d7fe99a2 |
|
@ -7,7 +7,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
|||
private var networkMonitor: NWPathMonitor?
|
||||
|
||||
private var site: Site?
|
||||
private let log = Logger(subsystem: "net.defined.mobileNebula", category: "PacketTunnelProvider")
|
||||
private var log = Logger(subsystem: "net.defined.mobileNebula", category: "PacketTunnelProvider")
|
||||
private var nebula: MobileNebulaNebula?
|
||||
private var dnUpdater = DNUpdater()
|
||||
private var didSleep = false
|
||||
|
@ -106,7 +106,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
|||
try self.nebula?.reload(String(data: newSite.getConfig(), encoding: .utf8), key: newSite.getKey())
|
||||
|
||||
} catch {
|
||||
log.error("Got an error while updating nebula \(error.localizedDescription, privacy: .public)")
|
||||
self.log.error("Got an error while updating nebula \(error.localizedDescription, privacy: .public)")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
import NetworkExtension
|
||||
import MobileNebula
|
||||
import SwiftyJSON
|
||||
import os.log
|
||||
|
||||
let log = Logger(subsystem: "net.defined.mobileNebula", category: "Site")
|
||||
|
||||
extension String: Error {}
|
||||
|
||||
|
@ -433,7 +430,7 @@ struct IncomingSite: Codable {
|
|||
return
|
||||
}
|
||||
|
||||
log.notice("Saving to \(configPath, privacy: .public)")
|
||||
print("Saving to \(configPath)")
|
||||
do {
|
||||
if (self.key != nil) {
|
||||
let data = self.key!.data(using: .utf8)
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
import Foundation
|
||||
import os.log
|
||||
|
||||
class DNUpdater {
|
||||
private let apiClient = APIClient()
|
||||
private let timer = RepeatingTimer(timeInterval: 30) // 15 * 60 is 15 minutes
|
||||
private let log = Logger(subsystem: "net.defined.mobileNebula", category: "DNUpdater")
|
||||
private let timer = RepeatingTimer(timeInterval: 15 * 60) // 15 * 60 is 15 minutes
|
||||
|
||||
func updateAll(onUpdate: @escaping (Site) -> ()) {
|
||||
_ = SiteList{ (sites, _) -> () in
|
||||
|
@ -57,7 +55,7 @@ class DNUpdater {
|
|||
} catch (APIClientError.invalidCredentials) {
|
||||
if (!credentials.invalid) {
|
||||
try site.invalidateDNCredentials()
|
||||
log.notice("Invalidated credentials in site: \(site.name, privacy: .public)")
|
||||
print("Invalidated credentials in site \(site.name)")
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -65,7 +63,7 @@ class DNUpdater {
|
|||
|
||||
newSite?.save(manager: nil) { error in
|
||||
if (error != nil) {
|
||||
self.log.error("failed to save update: \(error!.localizedDescription, privacy: .public)")
|
||||
print("failed to save update: \(error!.localizedDescription)")
|
||||
} else {
|
||||
onUpdate(Site(incoming: newSite!))
|
||||
}
|
||||
|
@ -73,11 +71,11 @@ class DNUpdater {
|
|||
|
||||
if (credentials.invalid) {
|
||||
try site.validateDNCredentials()
|
||||
log.notice("Revalidated credentials in site \(site.name, privacy: .public)")
|
||||
print("Revalidated credentials in site \(site.name)")
|
||||
}
|
||||
|
||||
} catch {
|
||||
log.error("Error while updating \(site.name, privacy: .public): \(error.localizedDescription, privacy: .public)")
|
||||
print("Error while updating \(site.name): \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue