Underlying VPN Logic

This commit is contained in:
GFWFighter
2023-10-17 03:15:15 +03:30
parent 7b2129ad6d
commit fe7cdc276e
12 changed files with 869 additions and 28 deletions

40
ios/Shared/FilePath.swift Normal file
View File

@@ -0,0 +1,40 @@
//
// FilePath.swift
// SingBoxPacketTunnel
//
// Created by GFWFighter on 7/25/1402 AP.
//
import Foundation
public enum FilePath {
public static let packageName = {
Bundle.main.infoDictionary?["BASE_BUNDLE_IDENTIFIER"] as? String ?? "unknown"
}()
}
public extension FilePath {
static let groupName = "group.\(packageName)"
private static let defaultSharedDirectory: URL! = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: FilePath.groupName)
static let sharedDirectory = defaultSharedDirectory!
static let cacheDirectory = sharedDirectory
.appendingPathComponent("Library", isDirectory: true)
.appendingPathComponent("Caches", isDirectory: true)
static let assetsDirectory = cacheDirectory.appendingPathComponent("Assets", isDirectory: true)
static let workingDirectory = cacheDirectory.appendingPathComponent("Working", isDirectory: true)
}
public extension URL {
var fileName: String {
var path = relativePath
if let index = path.lastIndex(of: "/") {
path = String(path[path.index(index, offsetBy: 1)...])
}
return path
}
}