forked from zelo72/mastodon-ios
feat: add onion domain ATS exception rule. resolve #338
This commit is contained in:
parent
08a603c2b3
commit
e6ee02b2b9
|
@ -7,7 +7,7 @@
|
|||
<key>AppShared.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>27</integer>
|
||||
<integer>20</integer>
|
||||
</dict>
|
||||
<key>CoreDataStack.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
|
@ -102,7 +102,7 @@
|
|||
<key>MastodonIntent.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>28</integer>
|
||||
<integer>21</integer>
|
||||
</dict>
|
||||
<key>MastodonIntents.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
|
@ -122,7 +122,7 @@
|
|||
<key>ShareActionExtension.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>26</integer>
|
||||
<integer>19</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>SuppressBuildableAutocreation</key>
|
||||
|
|
|
@ -55,6 +55,15 @@
|
|||
"version": "1.2.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": "FLAnimatedImage",
|
||||
"repositoryURL": "https://github.com/Flipboard/FLAnimatedImage.git",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "e7f9fd4681ae41bf6f3056db08af4f401d61da52",
|
||||
"version": "1.0.16"
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": "FPSIndicator",
|
||||
"repositoryURL": "https://github.com/MainasuK/FPSIndicator.git",
|
||||
|
@ -207,6 +216,15 @@
|
|||
"revision": "d0470491f56e734731bbf77991944c0dfdee3e0e",
|
||||
"version": "2.6.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": "UITextView+Placeholder",
|
||||
"repositoryURL": "https://github.com/MainasuK/UITextView-Placeholder.git",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "20f513ded04a040cdf5467f0891849b1763ede3b",
|
||||
"version": "1.4.1"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -2,6 +2,19 @@
|
|||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSExceptionDomains</key>
|
||||
<dict>
|
||||
<key>onion</key>
|
||||
<dict>
|
||||
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
||||
<true/>
|
||||
<key>NSIncludesSubdomains</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>CADisableMinimumFrameDurationOnPhone</key>
|
||||
<true/>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
|
|
|
@ -148,7 +148,7 @@ extension NotificationTimelineViewModel {
|
|||
guard let authenticationBox = context.authenticationService.activeMastodonAuthenticationBox.value else { return }
|
||||
|
||||
isLoadingLatest = true
|
||||
defer{ isLoadingLatest = false }
|
||||
defer { isLoadingLatest = false }
|
||||
|
||||
do {
|
||||
_ = try await context.apiService.notifications(
|
||||
|
|
|
@ -16,7 +16,8 @@ import MastodonSDK
|
|||
extension APIService {
|
||||
|
||||
private static func webFingerEndpointURL(domain: String) -> URL {
|
||||
return URL(string: "https://\(domain)/")!
|
||||
|
||||
return URL(string: "\(URL.httpScheme(domain: domain))://\(domain)/")!
|
||||
.appendingPathComponent(".well-known")
|
||||
.appendingPathComponent("webfinger")
|
||||
}
|
||||
|
|
|
@ -74,27 +74,27 @@ extension Mastodon.API {
|
|||
}()
|
||||
|
||||
static func oauthEndpointURL(domain: String) -> URL {
|
||||
return URL(string: "https://" + domain + "/oauth/")!
|
||||
return URL(string: "\(URL.httpScheme(domain: domain))://" + domain + "/oauth/")!
|
||||
}
|
||||
static func endpointURL(domain: String) -> URL {
|
||||
return URL(string: "https://" + domain + "/api/v1/")!
|
||||
return URL(string: "\(URL.httpScheme(domain: domain))://" + domain + "/api/v1/")!
|
||||
}
|
||||
static func endpointV2URL(domain: String) -> URL {
|
||||
return URL(string: "https://" + domain + "/api/v2/")!
|
||||
return URL(string: "\(URL.httpScheme(domain: domain))://" + domain + "/api/v2/")!
|
||||
}
|
||||
|
||||
static let joinMastodonEndpointURL = URL(string: "https://api.joinmastodon.org/")!
|
||||
|
||||
public static func resendEmailURL(domain: String) -> URL {
|
||||
return URL(string: "https://" + domain + "/auth/confirmation/new")!
|
||||
return URL(string: "\(URL.httpScheme(domain: domain))://" + domain + "/auth/confirmation/new")!
|
||||
}
|
||||
|
||||
public static func serverRulesURL(domain: String) -> URL {
|
||||
return URL(string: "https://" + domain + "/about/more")!
|
||||
return URL(string: "\(URL.httpScheme(domain: domain))://" + domain + "/about/more")!
|
||||
}
|
||||
|
||||
public static func privacyURL(domain: String) -> URL {
|
||||
return URL(string: "https://" + domain + "/terms")!
|
||||
return URL(string: "\(URL.httpScheme(domain: domain))://" + domain + "/terms")!
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// URL.swift
|
||||
//
|
||||
//
|
||||
// Created by MainasuK on 2022-3-16.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
extension URL {
|
||||
public static func httpScheme(domain: String) -> String {
|
||||
return domain.hasSuffix(".onion") ? "http" : "https"
|
||||
}
|
||||
}
|
|
@ -22,7 +22,7 @@ extension MastodonSDKTests {
|
|||
os_log("%{public}s[%{public}ld], %{public}s: (%s) authorizeURL %s", ((#file as NSString).lastPathComponent), #line, #function, domain, authorizeURL.absoluteString)
|
||||
XCTAssertEqual(
|
||||
authorizeURL.absoluteString,
|
||||
"https://\(domain)/oauth/authorize?response_type=code&client_id=StubClientID&redirect_uri=mastodon://joinmastodon.org/oauth&scope=read%20write%20follow%20push"
|
||||
"\(URL.httpScheme(domain: domain))://\(domain)/oauth/authorize?response_type=code&client_id=StubClientID&redirect_uri=mastodon://joinmastodon.org/oauth&scope=read%20write%20follow%20push"
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
import XCTest
|
||||
@testable import Mastodon
|
||||
|
||||
@MainActor
|
||||
class MastodonTests: XCTestCase {
|
||||
|
||||
override func setUpWithError() throws {
|
||||
|
@ -43,4 +44,20 @@ extension MastodonTests {
|
|||
}
|
||||
wait(for: [expectation], timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 15.0, *)
|
||||
func testConnectOnion() async throws {
|
||||
let request = URLRequest(
|
||||
url: URL(string: "http://a232ncr7jexk2chvubaq2v6qdizbocllqap7mnn7w7vrdutyvu32jeyd.onion/@k0gen")!,
|
||||
cachePolicy: .reloadIgnoringLocalAndRemoteCacheData,
|
||||
timeoutInterval: 10
|
||||
)
|
||||
do {
|
||||
let data = try await URLSession.shared.data(for: request, delegate: nil)
|
||||
print(data)
|
||||
} catch {
|
||||
debugPrint(error)
|
||||
assertionFailure(error.localizedDescription)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue