mirror of
https://github.com/cranci1/Sora.git
synced 2026-01-11 20:10:24 +00:00
idk if this uses 1.1.1.1 DNS 😭
Some checks are pending
Build and Release IPA / Build IPA (push) Waiting to run
Some checks are pending
Build and Release IPA / Build IPA (push) Waiting to run
This commit is contained in:
parent
3661e601e5
commit
f030f65ce0
4 changed files with 24 additions and 7 deletions
|
|
@ -45,7 +45,7 @@ extension JSContext {
|
|||
request.setValue(value, forHTTPHeaderField: key)
|
||||
}
|
||||
}
|
||||
let task = URLSession.custom.dataTask(with: request) { data, _, error in
|
||||
let task = URLSession.cloudflareCustom.dataTask(with: request) { data, _, error in
|
||||
if let error = error {
|
||||
Logger.shared.log("Network error in fetchNativeFunction: \(error.localizedDescription)", type: "Error")
|
||||
reject.call(withArguments: [error.localizedDescription])
|
||||
|
|
@ -90,7 +90,7 @@ extension JSContext {
|
|||
request.setValue(value, forHTTPHeaderField: key)
|
||||
}
|
||||
}
|
||||
let task = URLSession.custom.dataTask(with: request) { data, response, error in
|
||||
let task = URLSession.cloudflareCustom.dataTask(with: request) { data, response, error in
|
||||
if let error = error {
|
||||
Logger.shared.log("Network error in fetchV2NativeFunction: \(error.localizedDescription)", type: "Error")
|
||||
reject.call(withArguments: [error.localizedDescription])
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
//
|
||||
|
||||
import Foundation
|
||||
import Network
|
||||
|
||||
extension URLSession {
|
||||
static let userAgents = [
|
||||
|
|
@ -45,4 +46,20 @@ extension URLSession {
|
|||
]
|
||||
return URLSession(configuration: configuration)
|
||||
}()
|
||||
|
||||
static let cloudflareCustom: URLSession = {
|
||||
let configuration = URLSessionConfiguration.default
|
||||
configuration.httpAdditionalHeaders = [
|
||||
"User-Agent": randomUserAgent
|
||||
]
|
||||
|
||||
let dnsSettings: [AnyHashable: Any] = [
|
||||
"DNSSettings": [
|
||||
"ServerAddresses": ["1.1.1.1", "1.0.0.1"]
|
||||
]
|
||||
]
|
||||
|
||||
configuration.connectionProxyDictionary = dnsSettings
|
||||
return URLSession(configuration: configuration)
|
||||
}()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class JSController: ObservableObject {
|
|||
return
|
||||
}
|
||||
|
||||
URLSession.custom.dataTask(with: url) { [weak self] data, _, error in
|
||||
URLSession.cloudflareCustom.dataTask(with: url) { [weak self] data, _, error in
|
||||
guard let self = self else { return }
|
||||
|
||||
if let error = error {
|
||||
|
|
@ -77,7 +77,7 @@ class JSController: ObservableObject {
|
|||
return
|
||||
}
|
||||
|
||||
URLSession.custom.dataTask(with: url) { [weak self] data, _, error in
|
||||
URLSession.cloudflareCustom.dataTask(with: url) { [weak self] data, _, error in
|
||||
guard let self = self else { return }
|
||||
|
||||
if let error = error {
|
||||
|
|
@ -130,7 +130,7 @@ class JSController: ObservableObject {
|
|||
return
|
||||
}
|
||||
|
||||
URLSession.custom.dataTask(with: url) { [weak self] data, _, error in
|
||||
URLSession.cloudflareCustom.dataTask(with: url) { [weak self] data, _, error in
|
||||
guard let self = self else { return }
|
||||
|
||||
if let error = error {
|
||||
|
|
@ -430,7 +430,7 @@ class JSController: ObservableObject {
|
|||
|
||||
func fetchStreamUrlJSSecond(episodeUrl: String, softsub: Bool = false, completion: @escaping ((stream: String?, subtitles: String?)) -> Void) {
|
||||
let url = URL(string: episodeUrl)!
|
||||
let task = URLSession.custom.dataTask(with: url) { data, response, error in
|
||||
let task = URLSession.cloudflareCustom.dataTask(with: url) { data, response, error in
|
||||
if let error = error {
|
||||
Logger.shared.log("URLSession error: \(error.localizedDescription)", type: "Error")
|
||||
DispatchQueue.main.async { completion((nil, nil)) }
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class VTTSubtitlesLoader: ObservableObject {
|
|||
|
||||
let format = determineSubtitleFormat(from: url)
|
||||
|
||||
URLSession.custom.dataTask(with: url) { data, _, error in
|
||||
URLSession.cloudflareCustom.dataTask(with: url) { data, _, error in
|
||||
guard let data = data,
|
||||
let content = String(data: data, encoding: .utf8),
|
||||
error == nil else { return }
|
||||
|
|
|
|||
Loading…
Reference in a new issue