mirror of
https://github.com/cranci1/Sora.git
synced 2026-03-11 17:45:37 +00:00
parent
63b1b20f5a
commit
c42d53f8f5
5 changed files with 1 additions and 186 deletions
|
|
@ -60,8 +60,7 @@ extension URLSession {
|
||||||
static let custom: URLSession = {
|
static let custom: URLSession = {
|
||||||
let configuration = URLSessionConfiguration.default
|
let configuration = URLSessionConfiguration.default
|
||||||
configuration.httpAdditionalHeaders = ["User-Agent": randomUserAgent]
|
configuration.httpAdditionalHeaders = ["User-Agent": randomUserAgent]
|
||||||
let session = URLSession(configuration: configuration)
|
return URLSession(configuration: configuration)
|
||||||
return DNSConfiguration.shared.configureDNS(for: session)
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
static func fetchData(allowRedirects:Bool) -> URLSession
|
static func fetchData(allowRedirects:Bool) -> URLSession
|
||||||
|
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
//
|
|
||||||
// DNSConfiguration.swift
|
|
||||||
// Sulfur
|
|
||||||
//
|
|
||||||
// Created by Francesco on 14/06/25.
|
|
||||||
//
|
|
||||||
|
|
||||||
import Network
|
|
||||||
import Foundation
|
|
||||||
|
|
||||||
enum DNSServer: String, CaseIterable {
|
|
||||||
case cloudflare = "1.1.1.1"
|
|
||||||
case cloudflareSecondary = "1.0.0.1"
|
|
||||||
case adGuard = "94.140.14.14"
|
|
||||||
case adGuardSecondary = "94.140.15.15"
|
|
||||||
case google = "8.8.8.8"
|
|
||||||
case googleSecondary = "8.8.4.4"
|
|
||||||
|
|
||||||
static var current: [DNSServer] = [.cloudflare, .cloudflareSecondary]
|
|
||||||
}
|
|
||||||
|
|
||||||
class DNSConfiguration {
|
|
||||||
static let shared = DNSConfiguration()
|
|
||||||
|
|
||||||
private init() {}
|
|
||||||
|
|
||||||
func configureDNS(for session: URLSession) -> URLSession {
|
|
||||||
let configuration = (session.configuration.copy() as! URLSessionConfiguration)
|
|
||||||
|
|
||||||
let proxyDict: [AnyHashable: Any] = [
|
|
||||||
kCFProxyTypeKey: kCFProxyTypeHTTPS,
|
|
||||||
kCFProxyHostNameKey: DNSServer.current[0].rawValue,
|
|
||||||
kCFProxyPortNumberKey: 443,
|
|
||||||
kCFProxyUsernameKey: "",
|
|
||||||
kCFProxyPasswordKey: ""
|
|
||||||
]
|
|
||||||
|
|
||||||
configuration.connectionProxyDictionary = proxyDict
|
|
||||||
|
|
||||||
return URLSession(configuration: configuration, delegate: session.delegate, delegateQueue: session.delegateQueue)
|
|
||||||
}
|
|
||||||
|
|
||||||
func setDNSServer(_ servers: [DNSServer]) {
|
|
||||||
DNSServer.current = servers
|
|
||||||
URLSession.shared.invalidateAndCancel()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,116 +0,0 @@
|
||||||
//
|
|
||||||
// SettingsViewDNS.swift
|
|
||||||
// Sulfur
|
|
||||||
//
|
|
||||||
// Created by Francesco on 14/06/25.
|
|
||||||
//
|
|
||||||
|
|
||||||
import SwiftUI
|
|
||||||
|
|
||||||
fileprivate struct SettingsSection<Content: View>: View {
|
|
||||||
let title: String
|
|
||||||
let footer: String?
|
|
||||||
let content: Content
|
|
||||||
|
|
||||||
init(title: String, footer: String? = nil, @ViewBuilder content: () -> Content) {
|
|
||||||
self.title = title
|
|
||||||
self.footer = footer
|
|
||||||
self.content = content()
|
|
||||||
}
|
|
||||||
|
|
||||||
var body: some View {
|
|
||||||
VStack(alignment: .leading, spacing: 4) {
|
|
||||||
Text(title.uppercased())
|
|
||||||
.font(.footnote)
|
|
||||||
.foregroundStyle(.gray)
|
|
||||||
.padding(.horizontal, 20)
|
|
||||||
|
|
||||||
VStack(spacing: 0) {
|
|
||||||
content
|
|
||||||
}
|
|
||||||
.background(.ultraThinMaterial)
|
|
||||||
.clipShape(RoundedRectangle(cornerRadius: 12))
|
|
||||||
.overlay(
|
|
||||||
RoundedRectangle(cornerRadius: 12)
|
|
||||||
.strokeBorder(
|
|
||||||
LinearGradient(
|
|
||||||
gradient: Gradient(stops: [
|
|
||||||
.init(color: Color.accentColor.opacity(0.3), location: 0),
|
|
||||||
.init(color: Color.accentColor.opacity(0), location: 1)
|
|
||||||
]),
|
|
||||||
startPoint: .top,
|
|
||||||
endPoint: .bottom
|
|
||||||
),
|
|
||||||
lineWidth: 0.5
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.padding(.horizontal, 20)
|
|
||||||
|
|
||||||
if let footer = footer {
|
|
||||||
Text(footer)
|
|
||||||
.font(.footnote)
|
|
||||||
.foregroundStyle(.gray)
|
|
||||||
.padding(.horizontal, 20)
|
|
||||||
.padding(.top, 4)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct SettingsViewDNS: View {
|
|
||||||
@State private var selectedDNS: [DNSServer] = DNSServer.current
|
|
||||||
|
|
||||||
var body: some View {
|
|
||||||
List {
|
|
||||||
SettingsSection(title: "DNS Server") {
|
|
||||||
ForEach(DNSServer.allCases.filter { $0.rawValue.hasSuffix(".14") || $0.rawValue.hasSuffix(".1") || $0.rawValue.hasSuffix(".8") }, id: \.self) { server in
|
|
||||||
Button(action: {
|
|
||||||
if let index = selectedDNS.firstIndex(of: server) {
|
|
||||||
selectedDNS.remove(at: index)
|
|
||||||
} else {
|
|
||||||
selectedDNS = [server]
|
|
||||||
if server == .cloudflare {
|
|
||||||
selectedDNS.append(.cloudflareSecondary)
|
|
||||||
} else if server == .adGuard {
|
|
||||||
selectedDNS.append(.adGuardSecondary)
|
|
||||||
} else if server == .google {
|
|
||||||
selectedDNS.append(.googleSecondary)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
DNSConfiguration.shared.setDNSServer(selectedDNS)
|
|
||||||
}) {
|
|
||||||
HStack {
|
|
||||||
VStack(alignment: .leading) {
|
|
||||||
Text(server.rawValue)
|
|
||||||
Text(serverDescription(server))
|
|
||||||
.font(.caption)
|
|
||||||
.foregroundColor(.gray)
|
|
||||||
}
|
|
||||||
Spacer()
|
|
||||||
if selectedDNS.contains(server) {
|
|
||||||
Image(systemName: "checkmark")
|
|
||||||
.foregroundColor(.accentColor)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Section(footer: Text("Using custom DNS servers can help protect your privacy and potentially block ads. Changes take effect immediately.")) {}
|
|
||||||
}
|
|
||||||
.navigationTitle("DNS Settings")
|
|
||||||
}
|
|
||||||
|
|
||||||
private func serverDescription(_ server: DNSServer) -> String {
|
|
||||||
switch server {
|
|
||||||
case .cloudflare:
|
|
||||||
return "Cloudflare (Fast & Private)"
|
|
||||||
case .adGuard:
|
|
||||||
return "AdGuard (Ad Blocking)"
|
|
||||||
case .google:
|
|
||||||
return "Google (Reliable)"
|
|
||||||
default:
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -216,11 +216,6 @@ struct SettingsView: View {
|
||||||
NavigationLink(destination: SettingsViewLogger()) {
|
NavigationLink(destination: SettingsViewLogger()) {
|
||||||
SettingsNavigationRow(icon: "doc.text", titleKey: "Logs")
|
SettingsNavigationRow(icon: "doc.text", titleKey: "Logs")
|
||||||
}
|
}
|
||||||
Divider().padding(.horizontal, 16)
|
|
||||||
|
|
||||||
NavigationLink(destination: SettingsViewDNS()) {
|
|
||||||
SettingsNavigationRow(icon: "server.rack", titleKey: "DNS")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.background(.ultraThinMaterial)
|
.background(.ultraThinMaterial)
|
||||||
.clipShape(RoundedRectangle(cornerRadius: 12))
|
.clipShape(RoundedRectangle(cornerRadius: 12))
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,6 @@
|
||||||
133D7C932D2BE2640075467E /* Modules.swift in Sources */ = {isa = PBXBuildFile; fileRef = 133D7C892D2BE2640075467E /* Modules.swift */; };
|
133D7C932D2BE2640075467E /* Modules.swift in Sources */ = {isa = PBXBuildFile; fileRef = 133D7C892D2BE2640075467E /* Modules.swift */; };
|
||||||
133D7C942D2BE2640075467E /* JSController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 133D7C8B2D2BE2640075467E /* JSController.swift */; };
|
133D7C942D2BE2640075467E /* JSController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 133D7C8B2D2BE2640075467E /* JSController.swift */; };
|
||||||
133F55BB2D33B55100E08EEA /* LibraryManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 133F55BA2D33B55100E08EEA /* LibraryManager.swift */; };
|
133F55BB2D33B55100E08EEA /* LibraryManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 133F55BA2D33B55100E08EEA /* LibraryManager.swift */; };
|
||||||
134ECCA42DFD649D00372FCE /* DNSConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 134ECCA32DFD649D00372FCE /* DNSConfiguration.swift */; };
|
|
||||||
134ECCA82DFD655700372FCE /* SettingsViewDNS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 134ECCA72DFD655700372FCE /* SettingsViewDNS.swift */; };
|
|
||||||
1359ED142D76F49900C13034 /* finTopView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1359ED132D76F49900C13034 /* finTopView.swift */; };
|
1359ED142D76F49900C13034 /* finTopView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1359ED132D76F49900C13034 /* finTopView.swift */; };
|
||||||
135CCBE22D4D1138008B9C0E /* SettingsViewPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 135CCBE12D4D1138008B9C0E /* SettingsViewPlayer.swift */; };
|
135CCBE22D4D1138008B9C0E /* SettingsViewPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 135CCBE12D4D1138008B9C0E /* SettingsViewPlayer.swift */; };
|
||||||
13637B8A2DE0EA1100BDA2FC /* UserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13637B892DE0EA1100BDA2FC /* UserDefaults.swift */; };
|
13637B8A2DE0EA1100BDA2FC /* UserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13637B892DE0EA1100BDA2FC /* UserDefaults.swift */; };
|
||||||
|
|
@ -147,8 +145,6 @@
|
||||||
133D7C892D2BE2640075467E /* Modules.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Modules.swift; sourceTree = "<group>"; };
|
133D7C892D2BE2640075467E /* Modules.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Modules.swift; sourceTree = "<group>"; };
|
||||||
133D7C8B2D2BE2640075467E /* JSController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSController.swift; sourceTree = "<group>"; };
|
133D7C8B2D2BE2640075467E /* JSController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSController.swift; sourceTree = "<group>"; };
|
||||||
133F55BA2D33B55100E08EEA /* LibraryManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LibraryManager.swift; sourceTree = "<group>"; };
|
133F55BA2D33B55100E08EEA /* LibraryManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LibraryManager.swift; sourceTree = "<group>"; };
|
||||||
134ECCA32DFD649D00372FCE /* DNSConfiguration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DNSConfiguration.swift; sourceTree = "<group>"; };
|
|
||||||
134ECCA72DFD655700372FCE /* SettingsViewDNS.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsViewDNS.swift; sourceTree = "<group>"; };
|
|
||||||
1359ED132D76F49900C13034 /* finTopView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = finTopView.swift; sourceTree = "<group>"; };
|
1359ED132D76F49900C13034 /* finTopView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = finTopView.swift; sourceTree = "<group>"; };
|
||||||
135CCBE12D4D1138008B9C0E /* SettingsViewPlayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewPlayer.swift; sourceTree = "<group>"; };
|
135CCBE12D4D1138008B9C0E /* SettingsViewPlayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewPlayer.swift; sourceTree = "<group>"; };
|
||||||
13637B892DE0EA1100BDA2FC /* UserDefaults.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaults.swift; sourceTree = "<group>"; };
|
13637B892DE0EA1100BDA2FC /* UserDefaults.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaults.swift; sourceTree = "<group>"; };
|
||||||
|
|
@ -382,7 +378,6 @@
|
||||||
133D7C832D2BE2630075467E /* SettingsSubViews */ = {
|
133D7C832D2BE2630075467E /* SettingsSubViews */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
134ECCA72DFD655700372FCE /* SettingsViewDNS.swift */,
|
|
||||||
1E9FF1D22D403E42008AC100 /* SettingsViewLoggerFilter.swift */,
|
1E9FF1D22D403E42008AC100 /* SettingsViewLoggerFilter.swift */,
|
||||||
1399FAD32D3AB38C00E97C31 /* SettingsViewLogger.swift */,
|
1399FAD32D3AB38C00E97C31 /* SettingsViewLogger.swift */,
|
||||||
133D7C842D2BE2630075467E /* SettingsViewModule.swift */,
|
133D7C842D2BE2630075467E /* SettingsViewModule.swift */,
|
||||||
|
|
@ -399,7 +394,6 @@
|
||||||
133D7C852D2BE2640075467E /* Utils */ = {
|
133D7C852D2BE2640075467E /* Utils */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
134ECCA22DFD649D00372FCE /* NetworkConfig */,
|
|
||||||
130326B42DF979A300AEF610 /* WebAuthentication */,
|
130326B42DF979A300AEF610 /* WebAuthentication */,
|
||||||
0457C5962DE7712A000AFBD9 /* ViewModifiers */,
|
0457C5962DE7712A000AFBD9 /* ViewModifiers */,
|
||||||
04F08EE02DE10C22006B29D9 /* Models */,
|
04F08EE02DE10C22006B29D9 /* Models */,
|
||||||
|
|
@ -481,14 +475,6 @@
|
||||||
path = Downloads;
|
path = Downloads;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
134ECCA22DFD649D00372FCE /* NetworkConfig */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
134ECCA32DFD649D00372FCE /* DNSConfiguration.swift */,
|
|
||||||
);
|
|
||||||
path = NetworkConfig;
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
1384DCDF2D89BE870094797A /* Helpers */ = {
|
1384DCDF2D89BE870094797A /* Helpers */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
|
@ -784,7 +770,6 @@
|
||||||
133F55BB2D33B55100E08EEA /* LibraryManager.swift in Sources */,
|
133F55BB2D33B55100E08EEA /* LibraryManager.swift in Sources */,
|
||||||
13E62FC42DABC58C0007E259 /* Trakt-Token.swift in Sources */,
|
13E62FC42DABC58C0007E259 /* Trakt-Token.swift in Sources */,
|
||||||
1398FB3F2DE4E161004D3F5F /* SettingsViewAbout.swift in Sources */,
|
1398FB3F2DE4E161004D3F5F /* SettingsViewAbout.swift in Sources */,
|
||||||
134ECCA82DFD655700372FCE /* SettingsViewDNS.swift in Sources */,
|
|
||||||
133D7C8E2D2BE2640075467E /* LibraryView.swift in Sources */,
|
133D7C8E2D2BE2640075467E /* LibraryView.swift in Sources */,
|
||||||
13E62FC72DABFE900007E259 /* TraktPushUpdates.swift in Sources */,
|
13E62FC72DABFE900007E259 /* TraktPushUpdates.swift in Sources */,
|
||||||
133D7C6E2D2BE2500075467E /* SoraApp.swift in Sources */,
|
133D7C6E2D2BE2500075467E /* SoraApp.swift in Sources */,
|
||||||
|
|
@ -806,7 +791,6 @@
|
||||||
7222485F2DCBAA2C00CABE2D /* DownloadModels.swift in Sources */,
|
7222485F2DCBAA2C00CABE2D /* DownloadModels.swift in Sources */,
|
||||||
722248602DCBAA2C00CABE2D /* M3U8StreamExtractor.swift in Sources */,
|
722248602DCBAA2C00CABE2D /* M3U8StreamExtractor.swift in Sources */,
|
||||||
13C0E5EA2D5F85EA00E7F619 /* ContinueWatchingManager.swift in Sources */,
|
13C0E5EA2D5F85EA00E7F619 /* ContinueWatchingManager.swift in Sources */,
|
||||||
134ECCA42DFD649D00372FCE /* DNSConfiguration.swift in Sources */,
|
|
||||||
13637B8A2DE0EA1100BDA2FC /* UserDefaults.swift in Sources */,
|
13637B8A2DE0EA1100BDA2FC /* UserDefaults.swift in Sources */,
|
||||||
0457C59D2DE78267000AFBD9 /* BookmarkGridView.swift in Sources */,
|
0457C59D2DE78267000AFBD9 /* BookmarkGridView.swift in Sources */,
|
||||||
0457C59E2DE78267000AFBD9 /* BookmarkLink.swift in Sources */,
|
0457C59E2DE78267000AFBD9 /* BookmarkLink.swift in Sources */,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue