Skip to content

Commit a0e9261

Browse files
committed
feat: synchronize code for v4.5.17
1 parent 50a2604 commit a0e9261

File tree

33 files changed

+45252
-11242
lines changed

33 files changed

+45252
-11242
lines changed

.twosky.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,19 @@
5151
"AdguardExtension/AdguardApp/UI/ViewControllers/RateApp/en.lproj/RateApp.strings",
5252
"AdguardExtension/AdguardApp/UI/ViewControllers/MainTabBar/MainPage/ImportSettings/en.lproj/ImportSettings.strings",
5353
"AdguardExtension/AdguardApp/UI/ViewControllers/UpsellViewController/en.lproj/UpsellViewController.strings",
54-
"AdguardExtension/YouTubeAdsActionExtension/en.lproj/InfoPlist.strings"
54+
"AdguardExtension/YouTubeAdsActionExtension/en.lproj/InfoPlist.strings",
55+
"AdguardExtension/Extension/Resources/en.lproj/AdguardBlockingExtensionAnnoyancesPlist.strings",
56+
"AdguardExtension/Extension/Resources/en.lproj/AdguardBlockingExtensionCustomPlist.strings",
57+
"AdguardExtension/Extension/Resources/en.lproj/AdguardBlockingExtensionGeneralPlist.strings",
58+
"AdguardExtension/Extension/Resources/en.lproj/AdguardBlockingExtensionOtherPlist.strings",
59+
"AdguardExtension/Extension/Resources/en.lproj/AdguardBlockingExtensionPrivacyPlist.strings",
60+
"AdguardExtension/Extension/Resources/en.lproj/AdguardBlockingExtensionSecurityPlist.strings",
61+
"AdguardExtension/Extension/Resources/en.lproj/ProBlockingExtensionAnnoyancesInfoPlist.strings",
62+
"AdguardExtension/Extension/Resources/en.lproj/ProBlockingExtensionCustomInfoPlist.strings",
63+
"AdguardExtension/Extension/Resources/en.lproj/ProBlockingExtensionGeneralInfoPlist.strings",
64+
"AdguardExtension/Extension/Resources/en.lproj/ProBlockingExtensionOtherInfoPlist.strings",
65+
"AdguardExtension/Extension/Resources/en.lproj/ProBlockingExtensionPrivacyInfoPlist.strings",
66+
"AdguardExtension/Extension/Resources/en.lproj/ProBlockingExtensionSecurityInfoPlist.strings"
5567
],
5668
"storyboard_dirs": [
5769
"AdguardExtension/AdguardApp/UI/ViewControllers/MainTabBar/MainMenu/About",

AdGuardSDK/AdGuardSDK.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3210,7 +3210,7 @@
32103210
isa = XCRemoteSwiftPackageReference;
32113211
repositoryURL = "https://github.com/AdguardTeam/DnsLibs";
32123212
requirement = {
3213-
branch = "v2.5.51@swift-5";
3213+
branch = "v2.8.25@swift-5";
32143214
kind = branch;
32153215
};
32163216
};
@@ -3235,7 +3235,7 @@
32353235
repositoryURL = "https://github.com/AdguardTeam/SafariConverterLib";
32363236
requirement = {
32373237
kind = exactVersion;
3238-
version = 3.1.0;
3238+
version = 4.2.1;
32393239
};
32403240
};
32413241
/* End XCRemoteSwiftPackageReference section */

AdGuardSDK/AdGuardSDK/DNS/PacketTunnelProvider/AGDnsProxy+Extension.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,12 @@ extension AGDnsProxyConfig {
150150
// Unfortunately, it appears to be really unstable and causing issues with the current implementation.
151151
// We should revive it later when we change the way the network extension handles network change.
152152
dnsProxyConfiguration.enableRouteResolver = false
153-
dnsProxyConfiguration.blockEch = false
153+
dnsProxyConfiguration.blockEch = defaultConfig.blockEch
154154
dnsProxyConfiguration.helperPath = defaultConfig.helperPath
155155
dnsProxyConfiguration.upstreamTimeoutMs = UInt(AGDnsProxyConfig.defaultTimeoutMs)
156-
dnsProxyConfiguration.enableServfailOnUpstreamsFailure = false // With DnsLibs 2.4.16+ we disable servfail on upstreams failure
156+
dnsProxyConfiguration.enableServfailOnUpstreamsFailure = defaultConfig.enableServfailOnUpstreamsFailure
157+
dnsProxyConfiguration.enableHttp3 = defaultConfig.enableHttp3
158+
dnsProxyConfiguration.enablePostQuantumCryptography = defaultConfig.enablePostQuantumCryptography
157159
return dnsProxyConfiguration
158160
}
159161

AdGuardSDK/AdGuardSDK/DNS/PacketTunnelProvider/DnsProxy.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ final class DnsProxy: DnsProxyProtocol {
6363
Logger.logInfo("(DnsProxy) - stop")
6464
self?.proxy?.stop()
6565
self?.proxy = nil
66+
Logger.logDebug("(DnsProxy) - stop; proxy stopped, calling reset")
6667
self?.proxySettingsProvider.reset()
6768
Logger.logInfo("(DnsProxy) - stopped")
6869
}
@@ -81,11 +82,14 @@ final class DnsProxy: DnsProxyProtocol {
8182

8283
// Configuration
8384
if proxy != nil {
85+
Logger.logDebug("(DnsProxy) - internalStart; stopping existing proxy")
8486
proxy?.stop()
8587
proxy = nil
8688
}
89+
Logger.logDebug("(DnsProxy) - internalStart; calling reset before getProxyConfig")
8790
proxySettingsProvider.reset()
8891
let configuration = proxySettingsProvider.getProxyConfig(systemDnsUpstreams, outboundInterface)
92+
Logger.logDebug("(DnsProxy) - internalStart; getProxyConfig done")
8993
let agConfig = AGDnsProxyConfig.initialize(from: configuration)
9094

9195
// Processing events config

AdGuardSDK/AdGuardSDK/DNS/PacketTunnelProvider/DnsProxyConfigurationProvider.swift

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ import Foundation
2020
import SharedAdGuardSDK
2121
import Network
2222

23+
/// Immutable snapshot of configuration state needed by event handler
24+
struct DnsProxyConfigurationSnapshot {
25+
let dnsUpstreamById: [Int: DnsProxyUpstream]
26+
let customDnsFilterIds: [Int]
27+
let dnsBlocklistFilterId: Int
28+
let dnsAllowlistFilterId: Int
29+
}
30+
2331
protocol DnsProxyConfigurationProviderProtocol {
2432
/**
2533
Contains all DNS upstreams that can resolve the request by unique ids
@@ -55,10 +63,15 @@ protocol DnsProxyConfigurationProviderProtocol {
5563

5664
/// Just clears `upstreamById`
5765
func reset()
66+
67+
/// Returns an atomic snapshot of all mutable configuration properties
68+
func snapshot() -> DnsProxyConfigurationSnapshot
5869
}
5970

6071
final class DnsProxyConfigurationProvider: DnsProxyConfigurationProviderProtocol {
6172

73+
private let lock = NSLock()
74+
6275
private(set) var dnsUpstreamById: [Int: DnsProxyUpstream] = [:]
6376
private(set) var customDnsFilterIds: [Int] = []
6477
private(set) var dnsBlocklistFilterId: Int = -1
@@ -86,7 +99,22 @@ final class DnsProxyConfigurationProvider: DnsProxyConfigurationProviderProtocol
8699
self.networkUtils = networkUtils
87100
}
88101

102+
func snapshot() -> DnsProxyConfigurationSnapshot {
103+
lock.lock()
104+
defer { lock.unlock() }
105+
let snap = DnsProxyConfigurationSnapshot(
106+
dnsUpstreamById: dnsUpstreamById,
107+
customDnsFilterIds: customDnsFilterIds,
108+
dnsBlocklistFilterId: dnsBlocklistFilterId,
109+
dnsAllowlistFilterId: dnsAllowlistFilterId
110+
)
111+
Logger.logDebug("(DnsProxyConfigurationProvider) - snapshot; upstreams=\(snap.dnsUpstreamById.count), customFilters=\(snap.customDnsFilterIds.count), blocklistId=\(snap.dnsBlocklistFilterId), allowlistId=\(snap.dnsAllowlistFilterId)")
112+
return snap
113+
}
114+
89115
func getProxyConfig(_ systemDnsUpstreams: [DnsUpstream], _ outboundInterface: NWInterface?) -> DnsProxyConfiguration {
116+
lock.lock()
117+
defer { lock.unlock() }
90118
let lowLevelConfiguration = dnsConfiguration.lowLevelConfiguration
91119

92120
// Reveal DNS bootstraps
@@ -143,6 +171,8 @@ final class DnsProxyConfigurationProvider: DnsProxyConfigurationProviderProtocol
143171
proxyFilters.append(allowlistFilter)
144172
}
145173

174+
Logger.logDebug("(DnsProxyConfigurationProvider) - getProxyConfig; done; upstreams=\(dnsUpstreamById.count), customFilters=\(customDnsFilterIds.count), blocklistId=\(dnsBlocklistFilterId), allowlistId=\(dnsAllowlistFilterId)")
175+
146176
return DnsProxyConfiguration(
147177
upstreams: proxyUpstreams,
148178
fallbacks: proxyFallbacks,
@@ -159,6 +189,9 @@ final class DnsProxyConfigurationProvider: DnsProxyConfigurationProviderProtocol
159189
}
160190

161191
func reset() {
192+
lock.lock()
193+
defer { lock.unlock() }
194+
Logger.logDebug("(DnsProxyConfigurationProvider) - reset; clearing \(dnsUpstreamById.count) upstreams")
162195
dnsUpstreamById.removeAll()
163196
customDnsFilterIds = []
164197
dnsBlocklistFilterId = -1

AdGuardSDK/AdGuardSDK/DNS/Statistics/ChartStatistics/ChartStatistics+Compress.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,16 @@ extension ChartStatistics {
3232
}
3333

3434
func compressTable() throws {
35-
Logger.logInfo("(ChartStatistics) - compressTable; Trying to compress the table")
35+
try statisticsDb.transaction(.immediate) {
36+
Logger.logInfo("(ChartStatistics) - compressTable; Trying to compress the table")
3637

37-
let recordsCountBeforeCompression = try statisticsDb.scalar(ChartStatisticsTable.table.count)
38-
let compressedRecords = try getCompressedRecords()
39-
try reset()
40-
try compressedRecords.forEach { try add(record: $0) }
38+
let recordsCountBeforeCompression = try statisticsDb.scalar(ChartStatisticsTable.table.count)
39+
let compressedRecords = try getCompressedRecords()
40+
try reset()
41+
try compressedRecords.forEach { try add(record: $0) }
4142

42-
Logger.logInfo("(ChartStatistics) - compressTable; Successfully compressed the table; from \(recordsCountBeforeCompression) to \(compressedRecords.count)")
43+
Logger.logInfo("(ChartStatistics) - compressTable; Successfully compressed the table; from \(recordsCountBeforeCompression) to \(compressedRecords.count)")
44+
}
4345
}
4446

4547
/// Returns specified `intervalsCount` number of date intervals for specified `period`

AdGuardSDK/AdGuardSDK/DNS/Statistics/DnsRequestProcessedEventHandler.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ final class DnsRequestProcessedEventHandler: DnsRequestProcessedEventHandlerProt
4848

4949
// TODO: - Add some tests
5050
func handle(event: AGDnsRequestProcessedEventWrapper) {
51+
let configSnapshot = proxyConfigurationProvider.snapshot()
52+
5153
eventQueue.async { [weak self] in
5254
guard let self = self, event.error == nil else {
5355
Logger.logError("(DnsRequestProcessedEventHandler) - handleEvent; Error: \(event.error ?? "Missing self")")
@@ -59,7 +61,10 @@ final class DnsRequestProcessedEventHandler: DnsRequestProcessedEventHandlerProt
5961
let activeDnsUpstream: DnsProxyUpstream?
6062

6163
if let upstreamId = event.upstreamId {
62-
activeDnsUpstream = self.proxyConfigurationProvider.dnsUpstreamById[upstreamId]
64+
activeDnsUpstream = configSnapshot.dnsUpstreamById[upstreamId]
65+
if activeDnsUpstream == nil {
66+
Logger.logDebug("(DnsRequestProcessedEventHandler) - handleEvent; upstreamId=\(upstreamId) not found in snapshot (snapshot has \(configSnapshot.dnsUpstreamById.count) upstreams)")
67+
}
6368
}
6469
else {
6570
activeDnsUpstream = nil
@@ -68,9 +73,9 @@ final class DnsRequestProcessedEventHandler: DnsRequestProcessedEventHandlerProt
6873
let processedEvent = DnsRequestProcessedEvent(
6974
event: event,
7075
upstream: activeDnsUpstream?.dnsUpstreamInfo,
71-
customDnsFilterIds: self.proxyConfigurationProvider.customDnsFilterIds,
72-
dnsBlocklistFilterId: self.proxyConfigurationProvider.dnsBlocklistFilterId,
73-
dnsAllowlistFilterId: self.proxyConfigurationProvider.dnsAllowlistFilterId
76+
customDnsFilterIds: configSnapshot.customDnsFilterIds,
77+
dnsBlocklistFilterId: configSnapshot.dnsBlocklistFilterId,
78+
dnsAllowlistFilterId: configSnapshot.dnsAllowlistFilterId
7479
)
7580

7681
// Add to statistics

AdGuardSDK/AdGuardSDK/DNS/Utils/NetworkUtils/NetworkUtils.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public class NetworkUtils: NetworkUtilsProtocol {
235235
return false
236236
}
237237

238-
private func logNWPath(_ newPath: NWPath) {
238+
private func logNWPath(_ newPath: Network.NWPath) {
239239
Logger.logInfo("(NetworkUtils) - NWPathMonitor received the current path update")
240240
Logger.logInfo("(NetworkUtils) - path status: \(newPath.status)")
241241
Logger.logInfo("(NetworkUtils) - path debugDescription: \(newPath.debugDescription)")

AdguardExtension/Adguard.xcodeproj/project.pbxproj

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4348,7 +4348,6 @@
43484348
D78238722E24F96200AA2B4A /* translator.ts */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.typescript; path = translator.ts; sourceTree = "<group>"; };
43494349
D78238762E24F99400AA2B4A /* index.ts */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.typescript; path = index.ts; sourceTree = "<group>"; };
43504350
D78238772E24F99400AA2B4A /* Storage.ts */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.typescript; path = Storage.ts; sourceTree = "<group>"; };
4351-
D78238792E24F9B500AA2B4A /* delayedEventDispatcher.ts */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.typescript; path = delayedEventDispatcher.ts; sourceTree = "<group>"; };
43524351
D782387A2E24F9C800AA2B4A /* adguard.ts */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.typescript; path = adguard.ts; sourceTree = "<group>"; };
43534352
D782387B2E24F9D300AA2B4A /* engine.ts */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.typescript; path = engine.ts; sourceTree = "<group>"; };
43544353
D782387D2E24FA1400AA2B4A /* jest-setup.ts */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.typescript; path = "jest-setup.ts"; sourceTree = "<group>"; };
@@ -5605,7 +5604,6 @@
56055604
children = (
56065605
4982C19826D78F2A00CACBBE /* assistant */,
56075606
4982C19A26D78F2A00CACBBE /* content.ts */,
5608-
D78238792E24F9B500AA2B4A /* delayedEventDispatcher.ts */,
56095607
4982C19B26D78F2A00CACBBE /* index.ts */,
56105608
);
56115609
path = content;
@@ -8451,7 +8449,7 @@
84518449
outputPaths = (
84528450
);
84538451
runOnlyForDeploymentPostprocessing = 0;
8454-
shellPath = "/bin/sh -l";
8452+
shellPath = "/bin/zsh -l";
84558453
shellScript = "set -e -x\n\nJS_SOURCES=\"${SRCROOT}/SafariWebExtension/extension\"\nRESOURCES=\"${SRCROOT}/SafariWebExtension/Resources\"\ncd \"${JS_SOURCES}\" && yarn install && ADG_PRO=1 yarn build && rm -rf \"${RESOURCES}/*\" && cp -r build/* \"${RESOURCES}\"\n";
84568454
};
84578455
4982C2F926D79F9500CACBBE /* ShellScript */ = {
@@ -8469,7 +8467,7 @@
84698467
outputPaths = (
84708468
);
84718469
runOnlyForDeploymentPostprocessing = 0;
8472-
shellPath = "/bin/sh -l";
8470+
shellPath = "/bin/zsh -l";
84738471
shellScript = "set -e -x\n\nJS_SOURCES=\"${SRCROOT}/SafariWebExtension/extension\"\nRESOURCES=\"${SRCROOT}/SafariWebExtension/Resources\"\ncd \"${JS_SOURCES}\" && yarn install && yarn build && rm -rf \"${RESOURCES}/*\" && cp -r build/* \"${RESOURCES}\"\n";
84748472
};
84758473
6506CC2B1BD853140020F31E /* Setting Required device capabilities */ = {
@@ -14628,7 +14626,7 @@
1462814626
isa = XCRemoteSwiftPackageReference;
1462914627
repositoryURL = "https://github.com/AdguardTeam/DnsLibs";
1463014628
requirement = {
14631-
branch = "v2.5.51@swift-5";
14629+
branch = "v2.8.25@swift-5";
1463214630
kind = branch;
1463314631
};
1463414632
};

AdguardExtension/AdguardApp/Info.plist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@
108108
<array>
109109
<string>fetch</string>
110110
</array>
111+
<key>UIDesignRequiresCompatibility</key>
112+
<true/>
111113
<key>UILaunchStoryboardName</key>
112114
<string>LaunchScreen</string>
113115
<key>UIMainStoryboardFile</key>

0 commit comments

Comments
 (0)