Skip to content

Commit

Permalink
rebuild V2rayUTool
Browse files Browse the repository at this point in the history
  • Loading branch information
yanue committed Jul 3, 2023
1 parent 579f67c commit 1dec271
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 697 deletions.
Binary file modified Build/V2rayUTool
Binary file not shown.
162 changes: 22 additions & 140 deletions V2rayU.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

55 changes: 0 additions & 55 deletions V2rayU/V2rayLaunch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -186,60 +186,5 @@ class V2rayLaunch: NSObject {

static func checkPorts() -> Bool {
return true
// stop old v2ray process
self.Stop()
// stop pac server
webServer.stop()

let localSockPort = UserDefaults.get(forKey: .localSockPort) ?? "1080"
let localSockHost = UserDefaults.get(forKey: .localSockHost) ?? "127.0.0.1"
let localHttpPort = UserDefaults.get(forKey: .localHttpPort) ?? "1087"
let localHttpHost = UserDefaults.get(forKey: .localHttpHost) ?? "127.0.0.1"
let localPacPort = UserDefaults.get(forKey: .localPacPort) ?? "11085"

// check same port
if localSockPort == localHttpPort {
makeToast(message: "the ports (sock,http) cannot be the same: " + localHttpPort)
return false
}

if localHttpPort == localPacPort {
makeToast(message: "the ports (http,pac) cannot be the same:" + localPacPort)
return false
}

if localSockPort == localPacPort {
makeToast(message: "the ports (sock,pac) cannot be the same:" + localPacPort)
return false
}

// check port is used
if !self.checkPort(host: localSockHost, port: localSockPort, tip: "socks") {
return false
}

if !self.checkPort(host: localHttpHost, port: localHttpPort, tip: "http") {
return false
}

if !self.checkPort(host: "0.0.0.0", port: localPacPort, tip: "pac") {
return false
}

return true
}

static func checkPort(host: String, port: String, tip: String) -> Bool {
// shell("/bin/bash",["-c","cd ~ && ls -la"])
let cmd = "cd " + AppHomePath + " && chmod +x ./V2rayUHelper && ./V2rayUHelper -cmd port -h " + host + " -p " + port
let res = shell(launchPath: "/bin/bash", arguments: ["-c", cmd])

NSLog("checkPort: res=(\(String(describing: res))) cmd=(\(cmd))")

if res != "ok" {
makeToast(message: tip + " error - " + (res ?? ""), displayDuration: 5)
return false
}
return true
}
}
6 changes: 0 additions & 6 deletions V2rayU/cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,4 @@ sudo chown root:admin ${cmd}
sudo chmod a+rx ${cmd}
sudo chmod +s ${cmd}

cmd="./V2rayUHelper"

sudo chown root:admin ${cmd}
sudo chmod a+rx ${cmd}
sudo chmod +s ${cmd}

echo 'done'
6 changes: 0 additions & 6 deletions V2rayU/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ rm -fr ~/.V2rayU/v2ray-core
rm -fr ~/.V2rayU/pac

# copy
\cp -rv ./V2rayUHelper ~/.V2rayU/
\cp -rf ./V2rayUTool ~/.V2rayU/
\cp -rv ./cmd.sh ~/.V2rayU/
\cp -rf ./pac ~/.V2rayU/
Expand All @@ -34,10 +33,5 @@ sudo chown root:admin ${cmd}
sudo chmod a+rx ${cmd}
sudo chmod +s ${cmd}

cmd="./V2rayUHelper"
sudo chown root:admin ${cmd}
sudo chmod a+rx ${cmd}
sudo chmod +s ${cmd}

echo 'done'

14 changes: 0 additions & 14 deletions V2rayU/ping.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,6 @@ class PingSpeed: NSObject {
}
}

func pingInCmd() {
let cmd = "cd " + AppHomePath + " && chmod +x ./V2rayUHelper && ./V2rayUHelper -cmd ping -t 5s -f ./" + pingJsonFileName
// print("cmd", cmd)
let res = runShell(launchPath: "/bin/bash", arguments: ["-c", cmd])

NSLog("pingInCmd: res=(\(String(describing: res))) cmd=(\(cmd))")

// 这里直接判断ok有问题,res里面还有lookup
if res?.contains("ok config.") ?? false {
// res is: ok config.xxxx
fastV2rayName = res!.replacingOccurrences(of: "ok ", with: "")
}
}

func parsePingResult() {
let jsonText = try? String(contentsOfFile: pingJsonFilePath, encoding: String.Encoding.utf8)
guard let json = try? JSON(data: (jsonText ?? "").data(using: String.Encoding.utf8, allowLossyConversion: false)!) else {
Expand Down
22 changes: 0 additions & 22 deletions V2rayUTests/Info.plist

This file was deleted.

164 changes: 0 additions & 164 deletions V2rayUTests/Sample.swift

This file was deleted.

Loading

0 comments on commit 1dec271

Please sign in to comment.