From d7ad0ad2da74140d2ca3480c21a1940744d2e61c Mon Sep 17 00:00:00 2001 From: yanue Date: Sun, 21 Jul 2024 16:14:51 +0800 Subject: [PATCH] =?UTF-8?q?=20vless=20security=20=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=80=BC=20none?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- V2rayU/Import.swift | 13 ++++++++++-- V2rayU/Preference/PreferencePac.swift | 30 ++++++++++++++++++++------- V2rayU/v2ray/V2rayConfig.swift | 6 ++++++ 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/V2rayU/Import.swift b/V2rayU/Import.swift index 5dc311a..fd96ff9 100644 --- a/V2rayU/Import.swift +++ b/V2rayU/Import.swift @@ -296,6 +296,16 @@ class ImportUri { } func importVless(vmess: VlessUri) { + if vmess.fp.isEmpty { + vmess.fp = "chrome" + } + if vmess.security.isEmpty { + vmess.security = "none" + } + if vmess.flow.isEmpty { + vmess.flow = "xtls-rprx-vision" + } + let v2ray = V2rayConfig() v2ray.serverProtocol = V2rayProtocolOutbound.vless.rawValue @@ -398,7 +408,6 @@ class ImportUri { svr.address = trojan.host svr.port = trojan.port svr.password = trojan.password - svr.flow = trojan.flow v2ray.serverTrojan = svr v2ray.enableMux = false @@ -492,7 +501,7 @@ func importByClash(clash: clashProxy) -> ImportUri? { item.address = clash.server item.port = clash.port item.id = clash.uuid ?? "" - item.security = clash.cipher ?? "auto" + item.security = clash.cipher ?? "none" // vless encryption item.type = clash.network ?? "tcp" item.sni = clash.sni ?? clash.server if clash.security == "reality" { diff --git a/V2rayU/Preference/PreferencePac.swift b/V2rayU/Preference/PreferencePac.swift index e5d4817..6abc55b 100644 --- a/V2rayU/Preference/PreferencePac.swift +++ b/V2rayU/Preference/PreferencePac.swift @@ -109,14 +109,17 @@ final class PreferencePacViewController: NSViewController, PreferencePane { let session = URLSession(configuration: getProxyUrlSessionConfigure()) let task = session.dataTask(with: URLRequest(url: reqUrl)){(data: Data?, response: URLResponse?, error: Error?) in if error != nil { - self.tips.stringValue = "Failed to download latest GFW List: \(String(describing: error))" + DispatchQueue.main.async { + self.tips.stringValue = "Failed to download latest GFW List: \(String(describing: error))" + } } else { if data != nil { if let outputStr = String(data: data!, encoding: String.Encoding.utf8) { do { try outputStr.write(toFile: GFWListFilePath, atomically: true, encoding: String.Encoding.utf8) - - self.tips.stringValue = "gfwList has been updated" + DispatchQueue.main.async { + self.tips.stringValue = "gfwList has been updated" + } NSLog("\(self.tips.stringValue)") // save to UserDefaults @@ -124,20 +127,28 @@ final class PreferencePacViewController: NSViewController, PreferencePane { if GeneratePACFile(rewrite: true) { // Popup a user notification - self.tips.stringValue = "PAC has been updated by latest GFW List." + DispatchQueue.main.async { + self.tips.stringValue = "PAC has been updated by latest GFW List." + } NSLog("\(self.tips.stringValue)") } } catch { // Popup a user notification - self.tips.stringValue = "Failed to Write latest GFW List." + DispatchQueue.main.async { + self.tips.stringValue = "Failed to Write latest GFW List." + } NSLog("\(self.tips.stringValue)") } } else { - self.tips.stringValue = "Failed to download latest GFW List." + DispatchQueue.main.async { + self.tips.stringValue = "Failed to download latest GFW List." + } } } else { // Popup a user notification - self.tips.stringValue = "Failed to download latest GFW List." + DispatchQueue.main.async { + self.tips.stringValue = "Failed to download latest GFW List." + } self.tryDownloadByShell(gfwPacListUrl: gfwPacListUrl) } } @@ -153,7 +164,9 @@ final class PreferencePacViewController: NSViewController, PreferencePane { NSLog("curl result: \(msg)") if GeneratePACFile(rewrite: true) { // Popup a user notification - self.tips.stringValue = "PAC has been updated by latest GFW List." + DispatchQueue.main.async { + self.tips.stringValue = "PAC has been updated by latest GFW List." + } } } } @@ -256,6 +269,7 @@ func getPacUserRules() -> String { ||github.com ||chat.openai.com ||openai.com + ||chatgpt.com """ do { let url = URL(fileURLWithPath: PACUserRuleFilePath) diff --git a/V2rayU/v2ray/V2rayConfig.swift b/V2rayU/v2ray/V2rayConfig.swift index 55c4692..ce09939 100644 --- a/V2rayU/v2ray/V2rayConfig.swift +++ b/V2rayU/v2ray/V2rayConfig.swift @@ -770,6 +770,12 @@ class V2rayConfig: NSObject { user.id = val["id"].stringValue user.flow = val["flow"].stringValue user.encryption = val["encryption"].stringValue + if user.flow.isEmpty { + user.flow = "xtls-rprx-vision" + } + if user.encryption.isEmpty { + user.encryption = "none" + } user.level = val["level"].intValue users.append(user) }