mirror of
https://github.com/DefinedNet/mobile_nebula.git
synced 2025-09-07 19:46:06 +00:00
Compare commits
3 commits
f6016f5da8
...
bcfcadec8e
Author | SHA1 | Date | |
---|---|---|---|
|
bcfcadec8e | ||
|
330c8348fb | ||
|
69b0a4dafa |
9 changed files with 78 additions and 21 deletions
|
@ -36,6 +36,10 @@ class MainActivity: FlutterActivity() {
|
|||
private var apiClient: APIClient? = null
|
||||
private var sites: Sites? = null
|
||||
|
||||
// Don't attempt to unbind from the service unless the client has received some
|
||||
// information about the service's state.
|
||||
private var isServiceBound = false
|
||||
|
||||
// When starting a site we may need to request VPN permissions. These variables help us
|
||||
// maintain state while waiting for a permission result.
|
||||
private var startResult: MethodChannel.Result? = null
|
||||
|
@ -440,6 +444,7 @@ class MainActivity: FlutterActivity() {
|
|||
private val connection = object : ServiceConnection {
|
||||
override fun onServiceConnected(className: ComponentName, service: IBinder) {
|
||||
outMessenger = Messenger(service)
|
||||
isServiceBound = true
|
||||
|
||||
// We want to monitor the service for as long as we are connected to it.
|
||||
try {
|
||||
|
@ -461,6 +466,7 @@ class MainActivity: FlutterActivity() {
|
|||
|
||||
override fun onServiceDisconnected(arg0: ComponentName) {
|
||||
outMessenger = null
|
||||
isServiceBound = false
|
||||
if (activeSiteId != null) {
|
||||
//TODO: this indicates the service died, notify that it is disconnected
|
||||
}
|
||||
|
@ -510,7 +516,14 @@ class MainActivity: FlutterActivity() {
|
|||
msg.replyTo = inMessenger
|
||||
outMessenger!!.send(msg)
|
||||
// Unbind
|
||||
unbindService(connection)
|
||||
if (isServiceBound) {
|
||||
try {
|
||||
unbindService(connection)
|
||||
isServiceBound = false
|
||||
} catch (e: IllegalArgumentException) {
|
||||
Log.e(TAG, e.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
outMessenger = null
|
||||
}
|
||||
|
|
|
@ -219,7 +219,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
|||
return nil
|
||||
}
|
||||
|
||||
var error: Error?
|
||||
var error: (any Error)?
|
||||
var data: JSON?
|
||||
|
||||
// start command has special treatment due to needing to call two completers
|
||||
|
@ -264,27 +264,27 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
|||
}
|
||||
}
|
||||
|
||||
private func listHostmap(pending: Bool) -> (JSON?, Error?) {
|
||||
private func listHostmap(pending: Bool) -> (JSON?, (any Error)?) {
|
||||
var err: NSError?
|
||||
let res = nebula!.listHostmap(pending, error: &err)
|
||||
return (JSON(res), err)
|
||||
}
|
||||
|
||||
private func getHostInfo(args: JSON) -> (JSON?, Error?) {
|
||||
private func getHostInfo(args: JSON) -> (JSON?, (any Error)?) {
|
||||
var err: NSError?
|
||||
let res = nebula!.getHostInfo(
|
||||
byVpnIp: args["vpnIp"].string, pending: args["pending"].boolValue, error: &err)
|
||||
return (JSON(res), err)
|
||||
}
|
||||
|
||||
private func setRemoteForTunnel(args: JSON) -> (JSON?, Error?) {
|
||||
private func setRemoteForTunnel(args: JSON) -> (JSON?, (any Error)?) {
|
||||
var err: NSError?
|
||||
let res = nebula!.setRemoteForTunnel(
|
||||
args["vpnIp"].string, addr: args["addr"].string, error: &err)
|
||||
return (JSON(res), err)
|
||||
}
|
||||
|
||||
private func closeTunnel(args: JSON) -> (JSON?, Error?) {
|
||||
private func closeTunnel(args: JSON) -> (JSON?, (any Error)?) {
|
||||
let res = nebula!.closeTunnel(args["vpnIp"].string)
|
||||
return (JSON(res), nil)
|
||||
}
|
||||
|
|
|
@ -458,7 +458,7 @@ struct IncomingSite: Codable {
|
|||
|
||||
func save(
|
||||
manager: NETunnelProviderManager?, saveToManager: Bool = true,
|
||||
callback: @escaping (Error?) -> Void
|
||||
callback: @escaping ((any Error)?) -> Void
|
||||
) {
|
||||
let configPath: URL
|
||||
|
||||
|
@ -506,7 +506,7 @@ struct IncomingSite: Codable {
|
|||
}
|
||||
|
||||
private func saveToManager(
|
||||
manager: NETunnelProviderManager?, callback: @escaping (Error?) -> Void
|
||||
manager: NETunnelProviderManager?, callback: @escaping ((any Error)?) -> Void
|
||||
) {
|
||||
if manager != nil {
|
||||
// We need to refresh our settings to properly update config
|
||||
|
@ -524,7 +524,7 @@ struct IncomingSite: Codable {
|
|||
}
|
||||
|
||||
private func finishSaveToManager(
|
||||
manager: NETunnelProviderManager, callback: @escaping (Error?) -> Void
|
||||
manager: NETunnelProviderManager, callback: @escaping ((any Error)?) -> Void
|
||||
) {
|
||||
// Stuff our details in the protocol
|
||||
let proto =
|
||||
|
|
|
@ -49,7 +49,7 @@ class SiteList {
|
|||
"logs", isDirectory: false)
|
||||
}
|
||||
|
||||
init(completion: @escaping ([String: Site]?, Error?) -> Void) {
|
||||
init(completion: @escaping ([String: Site]?, (any Error)?) -> Void) {
|
||||
#if targetEnvironment(simulator)
|
||||
SiteList.loadAllFromFS { sites, err in
|
||||
if sites != nil {
|
||||
|
@ -67,7 +67,7 @@ class SiteList {
|
|||
#endif
|
||||
}
|
||||
|
||||
private static func loadAllFromFS(completion: @escaping ([String: Site]?, Error?) -> Void) {
|
||||
private static func loadAllFromFS(completion: @escaping ([String: Site]?, (any Error)?) -> Void) {
|
||||
let fileManager = FileManager.default
|
||||
var siteDirs: [URL]
|
||||
var sites = [String: Site]()
|
||||
|
@ -97,7 +97,9 @@ class SiteList {
|
|||
completion(sites, nil)
|
||||
}
|
||||
|
||||
private static func loadAllFromNETPM(completion: @escaping ([String: Site]?, Error?) -> Void) {
|
||||
private static func loadAllFromNETPM(
|
||||
completion: @escaping ([String: Site]?, (any Error)?) -> Void
|
||||
) {
|
||||
var sites = [String: Site]()
|
||||
|
||||
// dispatchGroup is used to ensure we have migrated all sites before returning them
|
||||
|
|
|
@ -563,6 +563,18 @@
|
|||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
SUPPORTED_PLATFORMS = iphoneos;
|
||||
SWIFT_UPCOMING_FEATURE_CONCISE_MAGIC_FILE = YES;
|
||||
SWIFT_UPCOMING_FEATURE_DEPRECATE_APPLICATION_MAIN = YES;
|
||||
SWIFT_UPCOMING_FEATURE_DISABLE_OUTWARD_ACTOR_ISOLATION = YES;
|
||||
SWIFT_UPCOMING_FEATURE_EXISTENTIAL_ANY = YES;
|
||||
SWIFT_UPCOMING_FEATURE_FORWARD_TRAILING_CLOSURES = YES;
|
||||
SWIFT_UPCOMING_FEATURE_GLOBAL_CONCURRENCY = YES;
|
||||
SWIFT_UPCOMING_FEATURE_IMPLICIT_OPEN_EXISTENTIALS = YES;
|
||||
SWIFT_UPCOMING_FEATURE_IMPORT_OBJC_FORWARD_DECLS = YES;
|
||||
SWIFT_UPCOMING_FEATURE_INFER_SENDABLE_FROM_CAPTURES = YES;
|
||||
SWIFT_UPCOMING_FEATURE_ISOLATED_DEFAULT_VALUES = YES;
|
||||
SWIFT_UPCOMING_FEATURE_REGION_BASED_ISOLATION = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
|
@ -772,6 +784,18 @@
|
|||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_UPCOMING_FEATURE_CONCISE_MAGIC_FILE = YES;
|
||||
SWIFT_UPCOMING_FEATURE_DEPRECATE_APPLICATION_MAIN = YES;
|
||||
SWIFT_UPCOMING_FEATURE_DISABLE_OUTWARD_ACTOR_ISOLATION = YES;
|
||||
SWIFT_UPCOMING_FEATURE_EXISTENTIAL_ANY = YES;
|
||||
SWIFT_UPCOMING_FEATURE_FORWARD_TRAILING_CLOSURES = YES;
|
||||
SWIFT_UPCOMING_FEATURE_GLOBAL_CONCURRENCY = YES;
|
||||
SWIFT_UPCOMING_FEATURE_IMPLICIT_OPEN_EXISTENTIALS = YES;
|
||||
SWIFT_UPCOMING_FEATURE_IMPORT_OBJC_FORWARD_DECLS = YES;
|
||||
SWIFT_UPCOMING_FEATURE_INFER_SENDABLE_FROM_CAPTURES = YES;
|
||||
SWIFT_UPCOMING_FEATURE_ISOLATED_DEFAULT_VALUES = YES;
|
||||
SWIFT_UPCOMING_FEATURE_REGION_BASED_ISOLATION = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Debug;
|
||||
|
@ -825,6 +849,18 @@
|
|||
SUPPORTED_PLATFORMS = iphoneos;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_UPCOMING_FEATURE_CONCISE_MAGIC_FILE = YES;
|
||||
SWIFT_UPCOMING_FEATURE_DEPRECATE_APPLICATION_MAIN = YES;
|
||||
SWIFT_UPCOMING_FEATURE_DISABLE_OUTWARD_ACTOR_ISOLATION = YES;
|
||||
SWIFT_UPCOMING_FEATURE_EXISTENTIAL_ANY = YES;
|
||||
SWIFT_UPCOMING_FEATURE_FORWARD_TRAILING_CLOSURES = YES;
|
||||
SWIFT_UPCOMING_FEATURE_GLOBAL_CONCURRENCY = YES;
|
||||
SWIFT_UPCOMING_FEATURE_IMPLICIT_OPEN_EXISTENTIALS = YES;
|
||||
SWIFT_UPCOMING_FEATURE_IMPORT_OBJC_FORWARD_DECLS = YES;
|
||||
SWIFT_UPCOMING_FEATURE_INFER_SENDABLE_FROM_CAPTURES = YES;
|
||||
SWIFT_UPCOMING_FEATURE_ISOLATED_DEFAULT_VALUES = YES;
|
||||
SWIFT_UPCOMING_FEATURE_REGION_BASED_ISOLATION = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
|
|
|
@ -318,13 +318,13 @@ func MissingArgumentError(message: String, details: Any?) -> FlutterError {
|
|||
}
|
||||
}
|
||||
|
||||
func MissingArgumentError(message: String, details: Error? = nil) -> FlutterError {
|
||||
func MissingArgumentError(message: String, details: (any Error)? = nil) -> FlutterError {
|
||||
return FlutterError(code: "missingArgument", message: message, details: details)
|
||||
}
|
||||
|
||||
func NoArgumentsError(
|
||||
message: String? = "no arguments were provided or could not be deserialized",
|
||||
details: Error? = nil
|
||||
details: (any Error)? = nil
|
||||
) -> FlutterError {
|
||||
return FlutterError(code: "noArguments", message: message, details: details)
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ class RepeatingTimer {
|
|||
self.timeInterval = timeInterval
|
||||
}
|
||||
|
||||
private lazy var timer: DispatchSourceTimer = {
|
||||
private lazy var timer: any DispatchSourceTimer = {
|
||||
let t = DispatchSource.makeTimerSource()
|
||||
t.schedule(deadline: .now(), repeating: self.timeInterval)
|
||||
t.setEventHandler(handler: { [weak self] in
|
||||
|
|
|
@ -13,13 +13,13 @@ class SiteContainer {
|
|||
|
||||
class Sites {
|
||||
private var containers = [String: SiteContainer]()
|
||||
private var messenger: FlutterBinaryMessenger?
|
||||
private var messenger: (any FlutterBinaryMessenger)?
|
||||
|
||||
init(messenger: FlutterBinaryMessenger?) {
|
||||
init(messenger: (any FlutterBinaryMessenger)?) {
|
||||
self.messenger = messenger
|
||||
}
|
||||
|
||||
func loadSites(completion: @escaping ([String: Site]?, Error?) -> Void) {
|
||||
func loadSites(completion: @escaping ([String: Site]?, (any Error)?) -> Void) {
|
||||
_ = SiteList { (sites, err) in
|
||||
if err != nil {
|
||||
return completion(nil, err)
|
||||
|
@ -42,7 +42,7 @@ class Sites {
|
|||
}
|
||||
}
|
||||
|
||||
func deleteSite(id: String, callback: @escaping (Error?) -> Void) {
|
||||
func deleteSite(id: String, callback: @escaping ((any Error)?) -> Void) {
|
||||
if let site = self.containers.removeValue(forKey: id) {
|
||||
_ = KeyChain.delete(key: "\(site.site.id).dnCredentials")
|
||||
_ = KeyChain.delete(key: "\(site.site.id).key")
|
||||
|
@ -85,9 +85,9 @@ class SiteUpdater: NSObject, FlutterStreamHandler {
|
|||
private var notification: Any?
|
||||
public var startFunc: (() -> Void)?
|
||||
private var configFd: Int32? = nil
|
||||
private var configObserver: DispatchSourceFileSystemObject? = nil
|
||||
private var configObserver: (any DispatchSourceFileSystemObject)? = nil
|
||||
|
||||
init(messenger: FlutterBinaryMessenger, site: Site) {
|
||||
init(messenger: any FlutterBinaryMessenger, site: Site) {
|
||||
do {
|
||||
let configPath = try SiteList.getSiteConfigFile(id: site.id, createDir: false)
|
||||
self.configFd = open(configPath.path, O_EVTONLY)
|
||||
|
|
|
@ -345,6 +345,12 @@ class MaterialTheme {
|
|||
textTheme: textTheme.apply(bodyColor: colorScheme.onSurface, displayColor: colorScheme.onSurface),
|
||||
scaffoldBackgroundColor: colorScheme.surface,
|
||||
canvasColor: colorScheme.surface,
|
||||
pageTransitionsTheme: PageTransitionsTheme(
|
||||
builders: Map<TargetPlatform, PageTransitionsBuilder>.fromIterable(
|
||||
TargetPlatform.values,
|
||||
value: (_) => const FadeForwardsPageTransitionsBuilder(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
List<ExtendedColor> get extendedColors => [];
|
||||
|
|
Loading…
Add table
Reference in a new issue