|
@@ -14,6 +14,7 @@ import UIKit
|
|
import FMDB
|
|
import FMDB
|
|
import QuickLook
|
|
import QuickLook
|
|
import NotificationBannerSwift
|
|
import NotificationBannerSwift
|
|
|
|
+import CallKit
|
|
|
|
|
|
public class Nexilis: NSObject {
|
|
public class Nexilis: NSObject {
|
|
public static var sAPIKey = ""
|
|
public static var sAPIKey = ""
|
|
@@ -169,29 +170,34 @@ public class Nexilis: NSObject {
|
|
Nexilis.ADDRESS = address.components(separatedBy: ":")[0]
|
|
Nexilis.ADDRESS = address.components(separatedBy: ":")[0]
|
|
Nexilis.PORT = Int(address.components(separatedBy: ":")[1]) ?? 0
|
|
Nexilis.PORT = Int(address.components(separatedBy: ":")[1]) ?? 0
|
|
// //print("IP PORT \(Nexilis.ADDRESS) <> \(Nexilis.PORT)")
|
|
// //print("IP PORT \(Nexilis.ADDRESS) <> \(Nexilis.PORT)")
|
|
- var id = ""
|
|
|
|
- if let device_id = UserDefaults.standard.string(forKey: "device_id") {
|
|
|
|
- try API.initConnection(bSwitchIP: false, sAPIK: apiKey, aAppMain: nil, cbiI: Callback(), sTCPAddr: Nexilis.ADDRESS, nTCPPort: Nexilis.PORT, sUserID: device_id, sStartWH: "09:00")
|
|
|
|
- } else if let me = UserDefaults.standard.string(forKey: "me") {
|
|
|
|
- try API.initConnection(bSwitchIP: false, sAPIK: apiKey, aAppMain: nil, cbiI: Callback(), sTCPAddr: Nexilis.ADDRESS, nTCPPort: Nexilis.PORT, sUserID: me, sStartWH: "09:00")
|
|
|
|
- } else {
|
|
|
|
- let uuid = UIDevice.current.identifierForVendor?.uuidString ?? "UNK-DEVICE"
|
|
|
|
- try API.initConnection(bSwitchIP: false, sAPIK: apiKey, aAppMain: nil, cbiI: Callback(), sTCPAddr: Nexilis.ADDRESS, nTCPPort: Nexilis.PORT, sUserID: uuid, sStartWH: "09:00")
|
|
|
|
- id = uuid
|
|
|
|
|
|
+ var id = Utils.getConnectionID()
|
|
|
|
+// if let device_id = UserDefaults.standard.string(forKey: "device_id") {
|
|
|
|
+// try API.initConnection(bSwitchIP: false, sAPIK: apiKey, aAppMain: nil, cbiI: Callback(), sTCPAddr: Nexilis.ADDRESS, nTCPPort: Nexilis.PORT, sUserID: device_id, sStartWH: "09:00")
|
|
|
|
+// } else if let me = UserDefaults.standard.string(forKey: "me") {
|
|
|
|
+// try API.initConnection(bSwitchIP: false, sAPIK: apiKey, aAppMain: nil, cbiI: Callback(), sTCPAddr: Nexilis.ADDRESS, nTCPPort: Nexilis.PORT, sUserID: me, sStartWH: "09:00")
|
|
|
|
+// } else {
|
|
|
|
+// let uuid = UIDevice.current.identifierForVendor?.uuidString ?? "UNK-DEVICE"
|
|
|
|
+// try API.initConnection(bSwitchIP: false, sAPIK: apiKey, aAppMain: nil, cbiI: Callback(), sTCPAddr: Nexilis.ADDRESS, nTCPPort: Nexilis.PORT, sUserID: uuid, sStartWH: "09:00")
|
|
|
|
+// id = uuid
|
|
|
|
+// }
|
|
|
|
+ if id.isEmpty {
|
|
|
|
+ id = UIDevice.current.identifierForVendor?.uuidString ?? "UNK-DEVICE"
|
|
|
|
+ Utils.setConnectionID(value: id)
|
|
}
|
|
}
|
|
|
|
+ try API.initConnection(bSwitchIP: false, sAPIK: apiKey, aAppMain: nil, cbiI: Callback(), sTCPAddr: Nexilis.ADDRESS, nTCPPort: Nexilis.PORT, sUserID: id, sStartWH: "09:00")
|
|
|
|
|
|
// wait until connection true
|
|
// wait until connection true
|
|
Nexilis.dispatch?.wait()
|
|
Nexilis.dispatch?.wait()
|
|
Nexilis.dispatch = nil
|
|
Nexilis.dispatch = nil
|
|
|
|
|
|
// Nexilis.initiateAudio()
|
|
// Nexilis.initiateAudio()
|
|
- if(!id.isEmpty && (UserDefaults.standard.string(forKey: "me") == nil)){
|
|
|
|
|
|
+ if(UserDefaults.standard.string(forKey: "me") == nil){
|
|
if let response = Nexilis.writeSync(message: CoreMessage_TMessageBank.getSignUpApi(api: apiKey, p_pin: id), timeout: 30 * 1000){
|
|
if let response = Nexilis.writeSync(message: CoreMessage_TMessageBank.getSignUpApi(api: apiKey, p_pin: id), timeout: 30 * 1000){
|
|
id = response.getBody(key: CoreMessage_TMessageKey.F_PIN, default_value: "")
|
|
id = response.getBody(key: CoreMessage_TMessageKey.F_PIN, default_value: "")
|
|
let enable_signup = (response.getBody(key: CoreMessage_TMessageKey.IS_ENABLED_ANONYMOUS, default_value: "0")) == "1"
|
|
let enable_signup = (response.getBody(key: CoreMessage_TMessageKey.IS_ENABLED_ANONYMOUS, default_value: "0")) == "1"
|
|
Utils.setForceAnonymous(value: enable_signup)
|
|
Utils.setForceAnonymous(value: enable_signup)
|
|
if(!id.isEmpty) {
|
|
if(!id.isEmpty) {
|
|
- Nexilis.changeUser(f_pin: id)
|
|
|
|
|
|
+// Nexilis.changeUser(f_pin: id)
|
|
UserDefaults.standard.setValue(id, forKey: "me")
|
|
UserDefaults.standard.setValue(id, forKey: "me")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -201,6 +207,8 @@ public class Nexilis: NSObject {
|
|
UserDefaults.standard.setValue(apiKey, forKey: "apiKey")
|
|
UserDefaults.standard.setValue(apiKey, forKey: "apiKey")
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ getFeatureAccess()
|
|
|
|
+
|
|
if let me = UserDefaults.standard.string(forKey: "me") {
|
|
if let me = UserDefaults.standard.string(forKey: "me") {
|
|
if Utils.getForceAnonymous() || (!Utils.getForceAnonymous() && Utils.getSetProfile()) {
|
|
if Utils.getForceAnonymous() || (!Utils.getForceAnonymous() && Utils.getSetProfile()) {
|
|
Database.shared.database?.inTransaction({ (fmdb, rollback) in
|
|
Database.shared.database?.inTransaction({ (fmdb, rollback) in
|
|
@@ -224,7 +232,6 @@ public class Nexilis: NSObject {
|
|
}
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- getFeatureAccess()
|
|
|
|
getServiceBank()
|
|
getServiceBank()
|
|
getPullWorkingArea()
|
|
getPullWorkingArea()
|
|
getPullGroupNoMember()
|
|
getPullGroupNoMember()
|
|
@@ -265,6 +272,87 @@ public class Nexilis: NSObject {
|
|
//print("MANIA \(UIFont.systemFont(ofSize: 12)) <> \(UIFont.italicSystemFont(ofSize: 12)) <> \(UIFont.boldSystemFont(ofSize: 12))")
|
|
//print("MANIA \(UIFont.systemFont(ofSize: 12)) <> \(UIFont.italicSystemFont(ofSize: 12)) <> \(UIFont.boldSystemFont(ofSize: 12))")
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private static func checkingEmulator() -> Bool {
|
|
|
|
+ if Utils.getCheckEmulator() {
|
|
|
|
+ #if arch(i386) || arch(x86_64)
|
|
|
|
+ UIApplication.shared.visibleViewController?.view.makeToast("121:Emulator detected".localized(), duration: 2)
|
|
|
|
+ return true
|
|
|
|
+ #else
|
|
|
|
+ #endif
|
|
|
|
+ }
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static func checkingRooted() -> Bool {
|
|
|
|
+ if Utils.getCheckRooted() {
|
|
|
|
+ #if arch(i386) || arch(x86_64)
|
|
|
|
+ return false
|
|
|
|
+ #else
|
|
|
|
+ let fileManager = FileManager.default
|
|
|
|
+ if fileManager.fileExists(atPath: "/Applications/Cydia.app") ||
|
|
|
|
+ fileManager.fileExists(atPath: "/Library/MobileSubstrate/MobileSubstrate.dylib") ||
|
|
|
|
+ fileManager.fileExists(atPath: "/bin/bash") ||
|
|
|
|
+ fileManager.fileExists(atPath: "/usr/sbin/sshd") ||
|
|
|
|
+ fileManager.fileExists(atPath: "/etc/apt") ||
|
|
|
|
+ fileManager.fileExists(atPath: "/private/var/lib/apt/") ||
|
|
|
|
+ fileManager.fileExists(atPath: "/Applications/FakeApp.app") {
|
|
|
|
+ UIApplication.shared.visibleViewController?.view.makeToast("126:Device is jailbroken".localized(), duration: 2)
|
|
|
|
+ return true
|
|
|
|
+ }
|
|
|
|
+ #endif
|
|
|
|
+ }
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static var screen: UIView!
|
|
|
|
+ @objc static func preventScreenRecording() {
|
|
|
|
+ let isCaptured = UIScreen.main.isCaptured
|
|
|
|
+ //print("isCaptured: \(isCaptured)")
|
|
|
|
+ if isCaptured {
|
|
|
|
+ blurScreen()
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ removeBlurScreen()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static func blurScreen(style: UIBlurEffect.Style = UIBlurEffect.Style.regular) {
|
|
|
|
+ screen = UIScreen.main.snapshotView(afterScreenUpdates: false)
|
|
|
|
+ let blurEffect = UIBlurEffect(style: style)
|
|
|
|
+ let blurBackground = UIVisualEffectView(effect: blurEffect)
|
|
|
|
+ screen.addSubview(blurBackground)
|
|
|
|
+ blurBackground.frame = (screen.frame)
|
|
|
|
+ if let window = UIApplication.shared.windows.first {
|
|
|
|
+ window.addSubview(screen)
|
|
|
|
+ } else {
|
|
|
|
+ //print("window nil")
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static func removeBlurScreen() {
|
|
|
|
+ screen?.removeFromSuperview()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static func makeSecure(window: UIWindow) {
|
|
|
|
+ let field = UITextField()
|
|
|
|
+
|
|
|
|
+ let view = UIView(frame: CGRect(x: 0, y: 0, width: field.frame.self.width, height: field.frame.self.height))
|
|
|
|
+
|
|
|
|
+ let image = UIImageView(image: UIImage.imageWithColor(color: .black, size: CGSize(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)))
|
|
|
|
+ image.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
|
|
|
|
+
|
|
|
|
+ field.isSecureTextEntry = true
|
|
|
|
+
|
|
|
|
+ window.addSubview(field)
|
|
|
|
+ view.addSubview(image)
|
|
|
|
+
|
|
|
|
+ window.layer.superlayer?.addSublayer(field.layer)
|
|
|
|
+ field.layer.sublayers?.last!.addSublayer(window.layer)
|
|
|
|
+
|
|
|
|
+ field.leftView = view
|
|
|
|
+ field.leftViewMode = .always
|
|
|
|
+ }
|
|
|
|
+
|
|
public static func addFB(viewController: UIViewController, fromMAB: Bool) {
|
|
public static func addFB(viewController: UIViewController, fromMAB: Bool) {
|
|
if let keyWindow = UIApplication.shared.windows.first(where: { $0.isKeyWindow }) {
|
|
if let keyWindow = UIApplication.shared.windows.first(where: { $0.isKeyWindow }) {
|
|
keyWindow.addSubview(floatingButton)
|
|
keyWindow.addSubview(floatingButton)
|
|
@@ -355,23 +443,53 @@ public class Nexilis: NSObject {
|
|
|
|
|
|
private static func getFeatureAccess() {
|
|
private static func getFeatureAccess() {
|
|
DispatchQueue.global().asyncAfter(deadline: .now(), execute: {
|
|
DispatchQueue.global().asyncAfter(deadline: .now(), execute: {
|
|
- if let response = Nexilis.writeSync(message: CoreMessage_TMessageBank.getFeatureAccessAll(), timeout: 10 * 1000), response.isOk() {
|
|
|
|
- let data = response.getBody(key: CoreMessage_TMessageKey.DATA)
|
|
|
|
- if !data.isEmpty {
|
|
|
|
- if let jsonArray = try! JSONSerialization.jsonObject(with: data.data(using: String.Encoding.utf8)!, options: JSONSerialization.ReadingOptions()) as? [AnyObject] {
|
|
|
|
|
|
+ Utils.postDataWithCookiesAndUserAgent(from: URL(string: Utils.getDomainOpr() + "get_feature_access")!) { data, response, error in
|
|
|
|
+ if let data = data, let responseString = String(data: data, encoding: .utf8) {
|
|
|
|
+ if let jsonArray = try! JSONSerialization.jsonObject(with: responseString.data(using: String.Encoding.utf8)!, options: JSONSerialization.ReadingOptions()) as? [AnyObject] {
|
|
do {
|
|
do {
|
|
let umr = jsonArray[0]["upload_max_retry"] as? Int
|
|
let umr = jsonArray[0]["upload_max_retry"] as? Int
|
|
let umt = jsonArray[0]["upload_max_time"] as? Int64
|
|
let umt = jsonArray[0]["upload_max_time"] as? Int64
|
|
|
|
+ let checkEmu = jsonArray[0]["check_emulator"] as? String
|
|
|
|
+ let checkRooted = jsonArray[0]["check_rooted_device"] as? String
|
|
|
|
+ let checkScreenCapt = jsonArray[0]["check_screen_capture"] as? String
|
|
if umr != nil {
|
|
if umr != nil {
|
|
Utils.setMaxRetryUpload(value: "\(umr ?? 0)")
|
|
Utils.setMaxRetryUpload(value: "\(umr ?? 0)")
|
|
}
|
|
}
|
|
if umt != nil {
|
|
if umt != nil {
|
|
Utils.setMaxRetryTimeUpload(value: "\(umt ?? 0)")
|
|
Utils.setMaxRetryTimeUpload(value: "\(umt ?? 0)")
|
|
}
|
|
}
|
|
|
|
+ if checkEmu != nil {
|
|
|
|
+ Utils.setCheckEmulator(b: checkEmu == "1")
|
|
|
|
+ }
|
|
|
|
+ if checkRooted != nil {
|
|
|
|
+ Utils.setCheckRooted(b: checkRooted == "1")
|
|
|
|
+ }
|
|
|
|
+ if checkScreenCapt != nil {
|
|
|
|
+ Utils.setCheckScreenCapture(b: checkScreenCapt == "1")
|
|
|
|
+ }
|
|
} catch {
|
|
} catch {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if Utils.getCheckScreenCapture() {
|
|
|
|
+ NotificationCenter.default.addObserver(self, selector: #selector(preventScreenRecording), name: UIScreen.capturedDidChangeNotification, object: nil)
|
|
|
|
+ DispatchQueue.main.asyncAfter(deadline: .now() + 2, execute: {
|
|
|
|
+ if let window = UIApplication.shared.windows.first {
|
|
|
|
+ makeSecure(window: window)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ if checkingEmulator() {
|
|
|
|
+ DispatchQueue.main.asyncAfter(deadline: .now() + 1, execute: {
|
|
|
|
+ exit(0)
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if checkingRooted() {
|
|
|
|
+ DispatchQueue.main.asyncAfter(deadline: .now() + 1, execute: {
|
|
|
|
+ exit(0)
|
|
|
|
+ })
|
|
|
|
+ }
|
|
}
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|