Skip to content

Commit

Permalink
remove v2ray-core update, remove auto login, check if need install
Browse files Browse the repository at this point in the history
  • Loading branch information
yanue committed Sep 1, 2023
1 parent 4620f6b commit 0e60cc3
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 366 deletions.
171 changes: 4 additions & 167 deletions V2rayU.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

11 changes: 0 additions & 11 deletions V2rayU/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
Analytics.self,
Crashes.self
])

// check v2ray core
V2rayCore().check()

// auto check updates
if UserDefaults.getBool(forKey: .autoCheckVersion) {
Expand Down Expand Up @@ -113,12 +110,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}

func checkDefault() {
if UserDefaults.get(forKey: .xRayCoreVersion) == nil {
UserDefaults.set(forKey: .xRayCoreVersion, value: V2rayCore.version)
}
if UserDefaults.get(forKey: .autoCheckVersion) == nil {
UserDefaults.setBool(forKey: .autoCheckVersion, value: true)
}
if UserDefaults.get(forKey: .autoUpdateServers) == nil {
UserDefaults.setBool(forKey: .autoUpdateServers, value: true)
}
Expand Down Expand Up @@ -162,8 +153,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
V2rayLaunch.Stop()
V2rayLaunch.Start()
}
// check v2ray core
V2rayCore().check()
// auto check updates
if UserDefaults.getBool(forKey: .autoCheckVersion) {
menuController.checkV2rayUVersion()
Expand Down
21 changes: 11 additions & 10 deletions V2rayU/Base.lproj/ConfigWindow.xib
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21701" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21225" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21701"/>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21225"/>
<capability name="System colors introduced in macOS 10.14" minToolsVersion="10.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down Expand Up @@ -100,7 +101,7 @@
<window title="V2rayU" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" animationBehavior="default" id="QvC-M9-y7g">
<windowStyleMask key="styleMask" titled="YES" closable="YES" fullSizeContentView="YES"/>
<rect key="contentRect" x="196" y="240" width="600" height="620"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1055"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1025"/>
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="600" height="620"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
Expand Down Expand Up @@ -136,7 +137,7 @@
</clipView>
<edgeInsets key="contentInsets" left="0.0" right="0.0" top="0.0" bottom="0.0"/>
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="CcG-vA-eQv">
<rect key="frame" x="1" y="184" width="148" height="15"/>
<rect key="frame" x="1" y="183" width="148" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="aeH-wA-qiH">
Expand Down Expand Up @@ -264,15 +265,15 @@ Gw
<rect key="frame" x="8" y="8" width="377" height="482"/>
<autoresizingMask key="autoresizingMask"/>
<clipView key="contentView" id="0rS-HW-TeI">
<rect key="frame" x="1" y="1" width="360" height="480"/>
<rect key="frame" x="1" y="1" width="375" height="480"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView importsGraphics="NO" richText="NO" verticallyResizable="YES" selectionGranularity="word" allowsUndo="YES" allowsNonContiguousLayout="YES" textCompletion="NO" smartInsertDelete="YES" id="dNK-7u-GUm">
<rect key="frame" x="0.0" y="0.0" width="364" height="480"/>
<rect key="frame" x="0.0" y="0.0" width="379" height="480"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="alternatingContentBackgroundColor" catalog="System" colorSpace="catalog"/>
<size key="minSize" width="360" height="480"/>
<size key="minSize" width="375" height="480"/>
<size key="maxSize" width="400" height="10000000"/>
<color key="insertionPointColor" name="textColor" catalog="System" colorSpace="catalog"/>
</textView>
Expand All @@ -284,7 +285,7 @@ Gw
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="PcW-ea-yMr">
<rect key="frame" x="361" y="1" width="15" height="480"/>
<rect key="frame" x="360" y="1" width="16" height="480"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
Expand Down Expand Up @@ -1965,7 +1966,7 @@ Gw
<userDefaultsController representsSharedInstance="YES" id="HhC-a7-Hqz"/>
</objects>
<resources>
<image name="NSAddTemplate" width="18" height="16"/>
<image name="NSMenuMixedStateTemplate" width="18" height="4"/>
<image name="NSAddTemplate" width="14" height="13"/>
<image name="NSMenuMixedStateTemplate" width="14" height="4"/>
</resources>
</document>
7 changes: 3 additions & 4 deletions V2rayU/V2rayCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ import SwiftyJSON

// v2ray-core version check, download, unzip
class V2rayCore {
static let version = "v1.5.4"
static let version = "v1.8.4"
// need replace ${version}
// "https://github.com/XTLS/Xray-core/releases/download/v1.4.2/Xray-macos-64.zip"
var x86_url: String = "https://github.com/XTLS/Xray-core/releases/download/v1.5.5/Xray-macos-64.zip"
var arm64_url: String = "https://github.com/XTLS/Xray-core/releases/download/v1.5.5/Xray-macos-arm64-v8a.zip"
var x86_url: String = "https://github.com/XTLS/Xray-core/releases/download/v1.8.4/Xray-macos-64.zip"
var arm64_url: String = "https://github.com/XTLS/Xray-core/releases/download/v1.8.4/Xray-macos-arm64-v8a.zip"
// last release version info
let versionUrl: String = "https://api.github.com/repos/XTLS/Xray-core/releases/latest"

Expand Down
33 changes: 20 additions & 13 deletions V2rayU/V2rayLaunch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import Swifter

let LAUNCH_AGENT_NAME = "yanue.v2rayu.v2ray-core"
let AppResourcesPath = Bundle.main.bundlePath + "/Contents/Resources"
let v2rayUTool = AppResourcesPath + "/V2rayUTool"
let AppHomePath = NSHomeDirectory() + "/.V2rayU"
let v2rayUTool = AppHomePath + "/V2rayUTool"
let v2rayCorePath = AppHomePath + "/v2ray-core"
let v2rayCoreFile = v2rayCorePath + "/v2ray"
let logFilePath = AppHomePath + "/v2ray-core.log"
Expand All @@ -39,28 +39,36 @@ class V2rayLaunch: NSObject {
// Ensure launch agent directory is existed.
let fileMgr = FileManager.default
if !fileMgr.fileExists(atPath: AppHomePath) {
print("app home dir \(AppHomePath) not exists,need install")
try! fileMgr.createDirectory(atPath: AppHomePath, withIntermediateDirectories: true, attributes: nil)
}

// make sure new version
print("install", AppResourcesPath)
var needRunInstall = false
if !FileManager.default.fileExists(atPath: v2rayCoreFile) {
print("app home dir not exists,need install")
print("\(v2rayCoreFile) not exists,need install")
needRunInstall = true
}

let launchKey = "launchedBefore-" + appVersion
let launchedBefore = UserDefaults.standard.bool(forKey: launchKey)
if !launchedBefore {
print("First launch, need install.")
UserDefaults.standard.set(true, forKey: launchKey)
if !FileManager.default.fileExists(atPath: v2rayUTool) {
print("\(v2rayUTool) not exists,need install")
needRunInstall = true
}

print("launchedBefore", launchedBefore, needRunInstall)
if !FileManager.default.fileExists(atPath: PACAbpFile) {
print("\(PACAbpFile) not exists,need install")
needRunInstall = true
}
if !FileManager.default.fileExists(atPath: GFWListFilePath) {
print("\(GFWListFilePath) not exists,need install")
needRunInstall = true
}
if !FileManager.default.fileExists(atPath: PACUserRuleFilePath) {
print("\(PACUserRuleFilePath) not exists,need install")
needRunInstall = true
}
print("launchedBefore", needRunInstall)
if !needRunInstall {
print("not install")
print("no need install")
return
}

Expand Down Expand Up @@ -152,8 +160,7 @@ class V2rayLaunch: NSObject {

static func setSystemProxy(mode: RunMode, httpPort: String = "", sockPort: String = "") {
// Ensure launch agent directory is existed.
let fileMgr = FileManager.default
if !fileMgr.isExecutableFile(atPath: v2rayUTool) {
if !FileManager.default.isExecutableFile(atPath: v2rayUTool) {
self.install()
}

Expand Down
17 changes: 0 additions & 17 deletions V2rayU/cmd.sh

This file was deleted.

32 changes: 15 additions & 17 deletions V2rayU/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,35 @@
# Created by yanue on 2021/01/30.
# Copyright © 2021 yanue. All rights reserved.

# remove old file
rm -fr ~/.V2rayU/v2ray-core
rm -fr ~/.V2rayU/pac
# replace V2rayUTool
rm -fr ~/.V2rayU/V2rayUTool
\cp -rf ./V2rayUTool ~/.V2rayU/

# root permission for change system proxy
cmd="./V2rayUTool"
sudo chown root:admin ${cmd}
sudo chmod a+rx ${cmd}
sudo chmod +s ${cmd}

# copy
\cp -rf ./pac ~/.V2rayU/
\cp -rf ./unzip.sh ~/.V2rayU/
# replace v2ray-core for new version
rm -fr ~/.V2rayU/v2ray-core
\cp -rf ./v2ray-core ~/.V2rayU/

# copy pac file if not exists
if [ ! -d "~/.V2rayU/pac" ]; then
\cp -rf ./pac ~/.V2rayU/
fi

# permission
sudo chown -R $USER ~/.V2rayU/
sudo chmod -R 777 ~/.V2rayU/

# root permission
cd ~/.V2rayU/

# root permission for change system proxy
cmd="./V2rayUTool"
sudo chown root:admin ${cmd}
sudo chmod a+rxs ${cmd}

# for apple silicon replace v2ray
if [[ $(arch) == 'arm64' ]]; then
\cp -rf ~/.V2rayU/v2ray-core/v2ray-arm64 ~/.V2rayU/v2ray-core/v2ray
fi

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

echo 'done'

24 changes: 0 additions & 24 deletions V2rayU/unzip.sh

This file was deleted.

63 changes: 0 additions & 63 deletions V2rayULauncher/AppDelegate.swift

This file was deleted.

32 changes: 0 additions & 32 deletions V2rayULauncher/Info.plist

This file was deleted.

8 changes: 0 additions & 8 deletions V2rayULauncher/V2rayULauncher.entitlements

This file was deleted.

0 comments on commit 0e60cc3

Please sign in to comment.