Skip to content

Commit

Permalink
vless security 默认值 none
Browse files Browse the repository at this point in the history
  • Loading branch information
yanue committed Jul 21, 2024
1 parent a7202a4 commit d7ad0ad
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 10 deletions.
13 changes: 11 additions & 2 deletions V2rayU/Import.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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" {
Expand Down
30 changes: 22 additions & 8 deletions V2rayU/Preference/PreferencePac.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,35 +109,46 @@ 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
UserDefaults.set(forKey: .gfwPacListUrl, value: gfwPacListUrl)

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)
}
}
Expand All @@ -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."
}
}
}
}
Expand Down Expand Up @@ -256,6 +269,7 @@ func getPacUserRules() -> String {
||github.com
||chat.openai.com
||openai.com
||chatgpt.com
"""
do {
let url = URL(fileURLWithPath: PACUserRuleFilePath)
Expand Down
6 changes: 6 additions & 0 deletions V2rayU/v2ray/V2rayConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit d7ad0ad

Please sign in to comment.