Skip to content

Commit

Permalink
Fix migration of DNS settings
Browse files Browse the repository at this point in the history
  • Loading branch information
keeshux committed Feb 6, 2025
1 parent 6b2ba28 commit f140b38
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Packages/App/Sources/LegacyV2/Domain/MapperV2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ extension MapperV2 {
extension MapperV2 {
func toNetworkModules(_ v2: ProfileV2.NetworkSettings) throws -> [Module] {
var modules: [Module] = []
if v2.dns.choice == .manual {
modules.append(try toDNSModule(v2.dns))
if v2.dns.choice == .manual, let dnsModule = try toDNSModule(v2.dns) {
modules.append(dnsModule)
}
if v2.proxy.choice == .manual {
modules.append(try toHTTPProxyModule(v2.proxy))
Expand All @@ -133,10 +133,13 @@ extension MapperV2 {
return modules
}

func toDNSModule(_ v2: Network.DNSSettings) throws -> DNSModule {
func toDNSModule(_ v2: Network.DNSSettings) throws -> DNSModule? {
var builder = DNSModule.Builder()
builder.protocolType = v2.dnsProtocol ?? .cleartext
builder.servers = v2.dnsServers ?? []
guard builder.protocolType != .cleartext || !builder.servers.isEmpty else {
return nil
}
builder.domainName = v2.dnsDomain
builder.searchDomains = v2.dnsSearchDomains
builder.dohURL = v2.dnsHTTPSURL?.absoluteString ?? ""
Expand Down

0 comments on commit f140b38

Please sign in to comment.