diff --git a/V2rayU/Import.swift b/V2rayU/Import.swift index 635cfdc..89b4e2c 100644 --- a/V2rayU/Import.swift +++ b/V2rayU/Import.swift @@ -204,6 +204,16 @@ class ImportUri { } func importVmess(vmess: VmessUri) { + if vmess.fp.isEmpty { + vmess.fp = "chrome" + } + if vmess.security.isEmpty { + vmess.security = "none" + } + if vmess.sni.count == 0 { + vmess.sni = vmess.address + } + let v2ray = V2rayConfig() var vmessItem = V2rayOutboundVMessItem() @@ -232,12 +242,10 @@ class ImportUri { v2ray.streamKcp.header.type = vmess.type v2ray.streamKcp.uplinkCapacity = vmess.uplinkCapacity v2ray.streamKcp.downlinkCapacity = vmess.downlinkCapacity + v2ray.streamKcp.seed = vmess.kcpSeed // h2 - if v2ray.streamH2.host.count == 0 { - v2ray.streamH2.host = [""] - } - v2ray.streamH2.host[0] = vmess.netHost + v2ray.streamH2.host = [vmess.netHost] v2ray.streamH2.path = vmess.netPath // ws @@ -311,6 +319,9 @@ class ImportUri { if vmess.flow.isEmpty { vmess.flow = "xtls-rprx-vision" } + if vmess.sni.count == 0 { + vmess.sni = vmess.address + } let v2ray = V2rayConfig() v2ray.serverProtocol = V2rayProtocolOutbound.vless.rawValue @@ -326,10 +337,6 @@ class ImportUri { vmessItem.users = [user] v2ray.serverVless = vmessItem - if vmess.sni.count == 0 { - vmess.sni = vmess.address - } - // stream v2ray.streamNetwork = vmess.type v2ray.streamSecurity = vmess.security @@ -345,12 +352,10 @@ class ImportUri { // kcp v2ray.streamKcp.header.type = vmess.type + v2ray.streamKcp.seed = vmess.kcpSeed // h2 - if v2ray.streamH2.host.count == 0 { - v2ray.streamH2.host = [""] - } - v2ray.streamH2.host[0] = vmess.host + v2ray.streamH2.host = [vmess.host] v2ray.streamH2.path = vmess.path // ws @@ -363,7 +368,13 @@ class ImportUri { // tcp v2ray.streamTcp.header.type = vmess.type - + if v2ray.streamNetwork == "tcp" && v2ray.streamTcp.header.type == "http" { + var tcpReq = TcpSettingHeaderRequest() + tcpReq.path = [vmess.path] + tcpReq.headers.host = [vmess.host] + v2ray.streamTcp.header.request = tcpReq + } + // quic v2ray.streamQuic.header.type = vmess.type diff --git a/V2rayU/Uri.swift b/V2rayU/Uri.swift index 4a253c1..1a0a25e 100644 --- a/V2rayU/Uri.swift +++ b/V2rayU/Uri.swift @@ -28,6 +28,8 @@ class VmessUri { var alpn: String = "" var sni: String = "" var fp: String = "" + var grpcMode:String = "" + var kcpSeed:String = "" /** vmess://base64(security:uuid@host:port)?[urlencode(parameters)] @@ -145,6 +147,13 @@ class VmessUri { case "remark": self.remark = param[1].urlDecoded() break + case "serviceName": + self.netPath = param[1] + break + case "mode": + self.grpcMode = param[1] + case "seed": + self.kcpSeed = param[1] default: break } @@ -219,6 +228,8 @@ class VmessUri { self.fp = json["fp"].stringValue // type:伪装类型(none\http\srtp\utp\wechat-video) self.type = json["type"].stringValue + self.kcpSeed = json["seed"].stringValue + self.grpcMode = json["mode"].stringValue } } @@ -520,6 +531,7 @@ class VlessUri { var pbk: String = "" // reality public key var sid: String = "" // reality shortId var grpcMode:String = "" + var kcpSeed:String = "" // vless://f2a5064a-fabb-43ed-a2b6-8ffeb970df7f@00.com:443?flow=xtls-rprx-splite&encryption=none&security=xtls&sni=aaaaa&type=http&host=00.com&path=%2fvl#vless1 func encode() -> String { @@ -539,6 +551,9 @@ class VlessUri { URLQueryItem(name: "fp", value: self.fp), URLQueryItem(name: "pbk", value: self.pbk), URLQueryItem(name: "sid", value: self.sid), + URLQueryItem(name: "serviceName", value: self.path), + URLQueryItem(name: "mode", value: self.grpcMode), + URLQueryItem(name: "seed", value: self.kcpSeed) ] return (uri.url?.absoluteString ?? "") + "#" + self.remark @@ -602,6 +617,12 @@ class VlessUri { case "sid": self.sid = item.value as! String break + case "headerType": + self.type = item.value as! String + break + case "seed": + self.kcpSeed = item.value as! String + break case "serviceName": self.path = item.value as! String break diff --git a/V2rayU/v2ray/v2rayStream.swift b/V2rayU/v2ray/v2rayStream.swift index 5e6be77..58edbfb 100644 --- a/V2rayU/v2ray/v2rayStream.swift +++ b/V2rayU/v2ray/v2rayStream.swift @@ -147,6 +147,7 @@ struct KcpSettings: Codable { var congestion: Bool = false var readBufferSize: Int = 1 var writeBufferSize: Int = 1 + var seed:String = "" var header: KcpSettingsHeader = KcpSettingsHeader() }