From 64f0eb4a7527451d728f2349c4195cf3895213d8 Mon Sep 17 00:00:00 2001 From: Xin Liu Date: Mon, 30 Sep 2024 08:32:55 -0700 Subject: [PATCH] Set DoH servers for the local gateway --- Planet/IPFS/IPFSCommand.swift | 9 +++++++++ Planet/IPFS/IPFSDaemon.swift | 18 ++++++++++++++++++ Planet/versioning.xcconfig | 2 +- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Planet/IPFS/IPFSCommand.swift b/Planet/IPFS/IPFSCommand.swift index b877463f..bb5b08ed 100644 --- a/Planet/IPFS/IPFSCommand.swift +++ b/Planet/IPFS/IPFSCommand.swift @@ -155,6 +155,15 @@ struct IPFSCommand { ]) } + static func setResolvers(resolversJSON: String) -> IPFSCommand { + IPFSCommand(arguments: [ + "config", + "DNS.Resolvers", + resolversJSON, + "--json", + ]) + } + static func setSwarmConnMgr(_ jsonString: String) -> IPFSCommand { IPFSCommand(arguments: [ "config", diff --git a/Planet/IPFS/IPFSDaemon.swift b/Planet/IPFS/IPFSDaemon.swift index 85416a04..27053261 100644 --- a/Planet/IPFS/IPFSDaemon.swift +++ b/Planet/IPFS/IPFSDaemon.swift @@ -214,6 +214,18 @@ actor IPFSDaemon { Self.logger.info("Unable to set peers for IPFS") } + Self.logger.info("Set DNS resolvers") + if let result = try? IPFSCommand.setResolvers( + resolversJSON: String(data: IPFSDaemon.resolvers.rawData(), encoding: .utf8)! + ).run(), + result.ret == 0 + { + Self.logger.info("Set DNS resolvers") + } + else { + Self.logger.info("Unable to set DNS resolvers") + } + let swarmConnMgr = JSON( [ "GracePeriod": "20s", @@ -757,6 +769,12 @@ extension IPFSDaemon { ], ] // Filebase ]) + // DoH resolvers + static let resolvers = JSON([ + "bit.": "https://dweb-dns.v2ex.pro/dns-query", + "sol.": "https://dweb-dns.v2ex.pro/dns-query", + "eth.": "https://dns.eth.limo/dns-query" + ]) static func urlForCID(_ cid: String) -> URL? { return URL(string: "https://\(cid).eth.sucks/") diff --git a/Planet/versioning.xcconfig b/Planet/versioning.xcconfig index dea613c8..b8d6f124 100644 --- a/Planet/versioning.xcconfig +++ b/Planet/versioning.xcconfig @@ -1 +1 @@ -CURRENT_PROJECT_VERSION = 2265 +CURRENT_PROJECT_VERSION = 2266