Skip to content

Commit

Permalink
feat: update V2RayCore.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
jurajhilje committed Sep 9, 2023
1 parent 52b77dd commit e920e57
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions IVPNClient/Models/V2Ray/V2RayCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,34 @@ class V2RayCore {

static let shared = V2RayCore()
private var core: CoreInstance?
private let configFile = "config.json"

// MARK: - Methods -

func start(completion: ((_ error: Error?) -> Void)?) {
if core != nil {
try? core?.close()
core = nil
var startError: Error? = nil

if let core = core {
do {
try core.close()
self.core = nil
} catch let error {
startError = error
}
}

var startError: Error? = nil
var configError: NSError?
let coreConfig = CoreLoadConfigFromJsonFile(configFile, &configError)
if configError != nil {
startError = configError as Error?
}

do {
let config = CoreConfig()
core = CoreNew(config, nil)
var initError: NSError?
core = CoreNew(coreConfig, &initError)
if initError != nil {
startError = initError as Error?
}
try core?.start()
} catch let error {
startError = error
Expand Down

0 comments on commit e920e57

Please sign in to comment.