Get ready for ios 15 (#47)
This commit is contained in:
parent
a1694727aa
commit
6c188ff1d1
|
@ -0,0 +1,16 @@
|
|||
#include <stdint.h>
|
||||
|
||||
/* <sys/kern_control.h> */
|
||||
#define CTLIOCGINFO 0xc0644e03UL
|
||||
struct ctl_info {
|
||||
u_int32_t ctl_id;
|
||||
char ctl_name[96];
|
||||
};
|
||||
struct sockaddr_ctl {
|
||||
u_char sc_len;
|
||||
u_char sc_family;
|
||||
u_int16_t ss_sysaddr;
|
||||
u_int32_t sc_id;
|
||||
u_int32_t sc_unit;
|
||||
u_int32_t sc_reserved[5];
|
||||
};
|
|
@ -5,7 +5,6 @@ import SwiftyJSON
|
|||
|
||||
class PacketTunnelProvider: NEPacketTunnelProvider {
|
||||
private var networkMonitor: NWPathMonitor?
|
||||
private var ifname: String?
|
||||
|
||||
private var site: Site?
|
||||
private var _log = OSLog(subsystem: "net.defined.mobileNebula", category: "PacketTunnelProvider")
|
||||
|
@ -56,19 +55,12 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
|||
} catch {
|
||||
return completionHandler(error)
|
||||
}
|
||||
|
||||
let fileDescriptor = (self.packetFlow.value(forKeyPath: "socket.fileDescriptor") as? Int32) ?? -1
|
||||
if fileDescriptor < 0 {
|
||||
return completionHandler("Starting tunnel failed: Could not determine file descriptor")
|
||||
|
||||
let fileDescriptor = tunnelFileDescriptor
|
||||
if fileDescriptor == nil {
|
||||
return completionHandler("Unable to locate the tun file descriptor")
|
||||
}
|
||||
|
||||
var ifnameSize = socklen_t(IFNAMSIZ)
|
||||
let ifnamePtr = UnsafeMutablePointer<CChar>.allocate(capacity: Int(ifnameSize))
|
||||
ifnamePtr.initialize(repeating: 0, count: Int(ifnameSize))
|
||||
if getsockopt(fileDescriptor, 2 /* SYSPROTO_CONTROL */, 2 /* UTUN_OPT_IFNAME */, ifnamePtr, &ifnameSize) == 0 {
|
||||
self.ifname = String(cString: ifnamePtr)
|
||||
}
|
||||
ifnamePtr.deallocate()
|
||||
let tunFD = Int(fileDescriptor!)
|
||||
|
||||
// This is set to 127.0.0.1 because it has to be something..
|
||||
let tunnelNetworkSettings = NEPacketTunnelNetworkSettings(tunnelRemoteAddress: "127.0.0.1")
|
||||
|
@ -100,7 +92,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
|||
}
|
||||
|
||||
var err: NSError?
|
||||
self.nebula = MobileNebulaNewNebula(String(data: config, encoding: .utf8), key, self.site!.logFile, Int(fileDescriptor), &err)
|
||||
self.nebula = MobileNebulaNewNebula(String(data: config, encoding: .utf8), key, self.site!.logFile, tunFD, &err)
|
||||
self.startNetworkMonitor()
|
||||
|
||||
if err != nil {
|
||||
|
@ -249,5 +241,37 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
|||
let res = nebula!.closeTunnel(args["vpnIp"].string)
|
||||
return (JSON(res), nil)
|
||||
}
|
||||
|
||||
private var tunnelFileDescriptor: Int32? {
|
||||
var ctlInfo = ctl_info()
|
||||
withUnsafeMutablePointer(to: &ctlInfo.ctl_name) {
|
||||
$0.withMemoryRebound(to: CChar.self, capacity: MemoryLayout.size(ofValue: $0.pointee)) {
|
||||
_ = strcpy($0, "com.apple.net.utun_control")
|
||||
}
|
||||
}
|
||||
for fd: Int32 in 0...1024 {
|
||||
var addr = sockaddr_ctl()
|
||||
var ret: Int32 = -1
|
||||
var len = socklen_t(MemoryLayout.size(ofValue: addr))
|
||||
withUnsafeMutablePointer(to: &addr) {
|
||||
$0.withMemoryRebound(to: sockaddr.self, capacity: 1) {
|
||||
ret = getpeername(fd, $0, &len)
|
||||
}
|
||||
}
|
||||
if ret != 0 || addr.sc_family != AF_SYSTEM {
|
||||
continue
|
||||
}
|
||||
if ctlInfo.ctl_id == 0 {
|
||||
ret = ioctl(fd, CTLIOCGINFO, &ctlInfo)
|
||||
if ret != 0 {
|
||||
continue
|
||||
}
|
||||
}
|
||||
if addr.sc_id == ctlInfo.ctl_id {
|
||||
return fd
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ PODS:
|
|||
- SDWebImageFLPlugin (0.4.0):
|
||||
- FLAnimatedImage (>= 1.0.11)
|
||||
- SDWebImage/Core (~> 5.6)
|
||||
- SwiftProtobuf (1.8.0)
|
||||
- SwiftProtobuf (1.9.0)
|
||||
- SwiftyJSON (5.0.1)
|
||||
- url_launcher (0.0.1):
|
||||
- Flutter
|
||||
|
@ -101,7 +101,7 @@ SPEC CHECKSUMS:
|
|||
path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c
|
||||
SDWebImage: 84000f962cbfa70c07f19d2234cbfcf5d779b5dc
|
||||
SDWebImageFLPlugin: 6c2295fb1242d44467c6c87dc5db6b0a13228fd8
|
||||
SwiftProtobuf: 2cbd9409689b7df170d82a92a33443c8e3e14a70
|
||||
SwiftProtobuf: ecbec1be9036d15655f6b3443a1c4ea693c97932
|
||||
SwiftyJSON: 2f33a42c6fbc52764d96f13368585094bfd8aa5e
|
||||
url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef
|
||||
|
||||
|
|
|
@ -69,6 +69,7 @@
|
|||
384887B4785D38431E800D3A /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
|
||||
41927814D2E140A347A01067 /* Pods-NebulaNetworkExtension.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NebulaNetworkExtension.debug.xcconfig"; path = "Target Support Files/Pods-NebulaNetworkExtension/Pods-NebulaNetworkExtension.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
436DE7A226EFF18500BB2950 /* CtlInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CtlInfo.h; sourceTree = "<group>"; };
|
||||
437F72582469AAC500A0C4B9 /* Site.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Site.swift; sourceTree = "<group>"; };
|
||||
437F725C2469AC5700A0C4B9 /* Keychain.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Keychain.swift; sourceTree = "<group>"; };
|
||||
43871C9A2444DD39004F9075 /* MobileNebula.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = MobileNebula.framework; sourceTree = "<group>"; };
|
||||
|
@ -82,8 +83,6 @@
|
|||
43AD63F324EB3802000FB47E /* Share.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Share.swift; sourceTree = "<group>"; };
|
||||
43B66ECA245A0C8400B18C36 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };
|
||||
43B66ECC245A146300B18C36 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||
43B828DA249C08DC00CA229C /* MMWormhole.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = MMWormhole.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
43E9BBD0251450C5000BFB8C /* MMWormhole.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = MMWormhole.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
53C42258A2092B55937DCF53 /* Pods-NebulaNetworkExtension.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NebulaNetworkExtension.profile.xcconfig"; path = "Target Support Files/Pods-NebulaNetworkExtension/Pods-NebulaNetworkExtension.profile.xcconfig"; sourceTree = "<group>"; };
|
||||
5C0A96949A0B117C4ACE752C /* Pods_NebulaNetworkExtension.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_NebulaNetworkExtension.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
6E7A71D8C71BF965D042667D /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
|
||||
|
@ -129,8 +128,6 @@
|
|||
43AA894D2444D8BC00EDC39C /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
43E9BBD0251450C5000BFB8C /* MMWormhole.framework */,
|
||||
43B828DA249C08DC00CA229C /* MMWormhole.framework */,
|
||||
43B66ECC245A146300B18C36 /* Foundation.framework */,
|
||||
43B66ECA245A0C8400B18C36 /* CoreFoundation.framework */,
|
||||
43AA894E2444D8BC00EDC39C /* NetworkExtension.framework */,
|
||||
|
@ -149,6 +146,7 @@
|
|||
43AA89582444DA6500EDC39C /* Info.plist */,
|
||||
43AA89592444DA6500EDC39C /* NebulaNetworkExtension.entitlements */,
|
||||
437F72582469AAC500A0C4B9 /* Site.swift */,
|
||||
436DE7A226EFF18500BB2950 /* CtlInfo.h */,
|
||||
);
|
||||
path = NebulaNetworkExtension;
|
||||
sourceTree = "<group>";
|
||||
|
@ -594,7 +592,7 @@
|
|||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Flutter",
|
||||
);
|
||||
MARKETING_VERSION = 0.0.41;
|
||||
MARKETING_VERSION = 0.0.43;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.defined.mobileNebula;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
|
@ -614,7 +612,7 @@
|
|||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CODE_SIGN_ENTITLEMENTS = NebulaNetworkExtension/NebulaNetworkExtension.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
CURRENT_PROJECT_VERSION = 5;
|
||||
DEVELOPMENT_TEAM = 576H3XS7FP;
|
||||
ENABLE_BITCODE = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
|
@ -625,7 +623,7 @@
|
|||
INFOPLIST_FILE = NebulaNetworkExtension/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
|
||||
MARKETING_VERSION = 0.0.41;
|
||||
MARKETING_VERSION = 0.0.42;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
OTHER_LDFLAGS = "";
|
||||
|
@ -633,6 +631,7 @@
|
|||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_OBJC_BRIDGING_HEADER = NebulaNetworkExtension/CtlInfo.h;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
|
@ -650,7 +649,7 @@
|
|||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CODE_SIGN_ENTITLEMENTS = NebulaNetworkExtension/NebulaNetworkExtension.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
CURRENT_PROJECT_VERSION = 5;
|
||||
DEVELOPMENT_TEAM = 576H3XS7FP;
|
||||
ENABLE_BITCODE = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
|
@ -661,12 +660,13 @@
|
|||
INFOPLIST_FILE = NebulaNetworkExtension/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
|
||||
MARKETING_VERSION = 0.0.41;
|
||||
MARKETING_VERSION = 0.0.42;
|
||||
MTL_FAST_MATH = YES;
|
||||
OTHER_LDFLAGS = "";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.defined.mobileNebula.NebulaNetworkExtension;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OBJC_BRIDGING_HEADER = NebulaNetworkExtension/CtlInfo.h;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
|
@ -683,7 +683,7 @@
|
|||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CODE_SIGN_ENTITLEMENTS = NebulaNetworkExtension/NebulaNetworkExtension.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
CURRENT_PROJECT_VERSION = 5;
|
||||
DEVELOPMENT_TEAM = 576H3XS7FP;
|
||||
ENABLE_BITCODE = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
|
@ -694,12 +694,13 @@
|
|||
INFOPLIST_FILE = NebulaNetworkExtension/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
|
||||
MARKETING_VERSION = 0.0.41;
|
||||
MARKETING_VERSION = 0.0.42;
|
||||
MTL_FAST_MATH = YES;
|
||||
OTHER_LDFLAGS = "";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.defined.mobileNebula.NebulaNetworkExtension;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OBJC_BRIDGING_HEADER = NebulaNetworkExtension/CtlInfo.h;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
|
@ -834,7 +835,7 @@
|
|||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Flutter",
|
||||
);
|
||||
MARKETING_VERSION = 0.0.41;
|
||||
MARKETING_VERSION = 0.0.43;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.defined.mobileNebula;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
|
@ -867,7 +868,7 @@
|
|||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Flutter",
|
||||
);
|
||||
MARKETING_VERSION = 0.0.41;
|
||||
MARKETING_VERSION = 0.0.43;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.defined.mobileNebula;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
|
|
|
@ -91,7 +91,7 @@ packages:
|
|||
name: file_picker
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.1"
|
||||
version: "3.0.2+2"
|
||||
fixnum:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -225,7 +225,7 @@ packages:
|
|||
name: protobuf
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.3"
|
||||
version: "1.1.4"
|
||||
pull_to_refresh:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -293,7 +293,7 @@ packages:
|
|||
name: url_launcher
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "6.0.3"
|
||||
version: "6.0.6"
|
||||
url_launcher_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -314,7 +314,7 @@ packages:
|
|||
name: url_launcher_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.2"
|
||||
version: "2.0.3"
|
||||
url_launcher_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -25,11 +25,11 @@ dependencies:
|
|||
cupertino_icons: ^1.0.2
|
||||
flutter_platform_widgets: ^1.2.0
|
||||
path_provider: ^2.0.1
|
||||
file_picker: ^3.0.1
|
||||
file_picker: ^3.0.2+2
|
||||
barcode_scan: ^3.0.1
|
||||
uuid: ^3.0.4
|
||||
package_info: ^2.0.0
|
||||
url_launcher: ^6.0.3
|
||||
url_launcher: ^6.0.6
|
||||
pull_to_refresh: ^1.6.5
|
||||
|
||||
dev_dependencies:
|
||||
|
|
Loading…
Reference in New Issue