mirror of
https://github.com/yanue/V2rayU.git
synced 2025-06-27 05:30:09 +00:00
Merge branch 'allrand-master'
This commit is contained in:
commit
7ca2b460d7
46
Podfile.lock
Normal file
46
Podfile.lock
Normal file
@ -0,0 +1,46 @@
|
||||
PODS:
|
||||
- Alamofire (4.8.2)
|
||||
- GCDWebServer (3.5.2):
|
||||
- GCDWebServer/Core (= 3.5.2)
|
||||
- GCDWebServer/Core (3.5.2)
|
||||
- Preferences (0.3.0)
|
||||
- QRCoder (1.1.0)
|
||||
- Sparkle (1.21.3)
|
||||
- SwiftyJSON (5.0.0)
|
||||
|
||||
DEPENDENCIES:
|
||||
- Alamofire
|
||||
- GCDWebServer (~> 3.5.2)
|
||||
- Preferences (from `https://github.com/sindresorhus/Preferences.git`)
|
||||
- QRCoder
|
||||
- Sparkle
|
||||
- SwiftyJSON
|
||||
|
||||
SPEC REPOS:
|
||||
https://github.com/CocoaPods/Specs.git:
|
||||
- Alamofire
|
||||
- GCDWebServer
|
||||
- QRCoder
|
||||
- Sparkle
|
||||
- SwiftyJSON
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
Preferences:
|
||||
:git: https://github.com/sindresorhus/Preferences.git
|
||||
|
||||
CHECKOUT OPTIONS:
|
||||
Preferences:
|
||||
:commit: e2e2aaba41b531a642934a17c9b37149dd1c294c
|
||||
:git: https://github.com/sindresorhus/Preferences.git
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
Alamofire: ae5c501addb7afdbb13687d7f2f722c78734c2d3
|
||||
GCDWebServer: ead88cd14596dd4eae4f5830b8877c87c8728990
|
||||
Preferences: 865793c3914c4de086c809a504a4157b8968cb90
|
||||
QRCoder: cbd2bee531cc86d286df7942334cfed94c803ae4
|
||||
Sparkle: 3f75576db8b0265adef36c43249d747f22d0b708
|
||||
SwiftyJSON: 36413e04c44ee145039d332b4f4e2d3e8d6c4db7
|
||||
|
||||
PODFILE CHECKSUM: 58098d0825211da73cdc15b835005b970bed1875
|
||||
|
||||
COCOAPODS: 1.8.4
|
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14868" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14868"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
|
||||
@ -365,6 +365,7 @@
|
||||
</menu>
|
||||
</menuItem>
|
||||
</items>
|
||||
<point key="canvasLocation" x="-502" y="336"/>
|
||||
</menu>
|
||||
</objects>
|
||||
</document>
|
||||
|
@ -9,6 +9,7 @@
|
||||
import Cocoa
|
||||
import Preferences
|
||||
import Alamofire
|
||||
import SwiftyJSON
|
||||
|
||||
final class PreferenceSubscribeViewController: NSViewController, PreferencePane {
|
||||
let preferencePaneIdentifier = PreferencePane.Identifier.subscribeTab
|
||||
@ -177,14 +178,20 @@ final class PreferenceSubscribeViewController: NSViewController, PreferencePane
|
||||
// remove old v2ray servers by subscribe
|
||||
V2rayServer.remove(subscribe: subscribe)
|
||||
|
||||
let id : String = String(url.suffix(32));
|
||||
|
||||
let list = strTmp!.trimmingCharacters(in: .newlines).components(separatedBy: CharacterSet.newlines)
|
||||
for item in list {
|
||||
// import every server
|
||||
self.importUri(uri: item.trimmingCharacters(in: .whitespacesAndNewlines), subscribe: subscribe)
|
||||
if (item.count == 0) {
|
||||
continue;
|
||||
} else {
|
||||
self.importUri(uri: item.trimmingCharacters(in: .whitespacesAndNewlines), subscribe: subscribe, id: id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func importUri(uri: String, subscribe: String) {
|
||||
func importUri(uri: String, subscribe: String, id: String) {
|
||||
if uri.count == 0 {
|
||||
logTip(title: "fail: ", uri: uri, informativeText: "uri not found")
|
||||
return
|
||||
@ -195,7 +202,7 @@ final class PreferenceSubscribeViewController: NSViewController, PreferencePane
|
||||
return
|
||||
}
|
||||
|
||||
if let importUri = ImportUri.importUri(uri: uri) {
|
||||
if let importUri = ImportUri.importUri(uri: uri, id: id) {
|
||||
if importUri.isValid {
|
||||
// add server
|
||||
V2rayServer.add(remark: importUri.remark, json: importUri.json, isValid: true, url: importUri.uri, subscribe: subscribe)
|
||||
|
@ -126,7 +126,7 @@ class ImportUri {
|
||||
var error: String = ""
|
||||
var uri: String = ""
|
||||
|
||||
static func importUri(uri: String, checkExist: Bool = true) -> ImportUri? {
|
||||
static func importUri(uri: String, id: String = "", checkExist: Bool = true) -> ImportUri? {
|
||||
if checkExist && V2rayServer.exist(url: uri) {
|
||||
let importUri = ImportUri()
|
||||
importUri.isValid = false
|
||||
@ -136,7 +136,7 @@ class ImportUri {
|
||||
|
||||
if uri.hasPrefix("vmess://") {
|
||||
let importUri = ImportUri()
|
||||
importUri.importVmessUri(uri: uri)
|
||||
importUri.importVmessUri(uri: uri, id: id)
|
||||
return importUri
|
||||
} else if uri.hasPrefix("ss://") {
|
||||
let importUri = ImportUri()
|
||||
@ -230,7 +230,7 @@ class ImportUri {
|
||||
}
|
||||
}
|
||||
|
||||
func importVmessUri(uri: String) {
|
||||
func importVmessUri(uri: String, id: String = "") {
|
||||
if URL(string: uri) == nil {
|
||||
self.error = "invalid vmess url"
|
||||
return
|
||||
@ -258,7 +258,8 @@ class ImportUri {
|
||||
vmessItem.address = vmess.address
|
||||
vmessItem.port = vmess.port
|
||||
var user = V2rayOutboundVMessUser()
|
||||
user.id = vmess.id
|
||||
vmess.id = id
|
||||
user.id = id
|
||||
user.alterId = vmess.alterId
|
||||
user.security = vmess.security
|
||||
vmessItem.users = [user]
|
||||
|
@ -7,7 +7,6 @@
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
import SwiftyJSON
|
||||
|
||||
// ----- v2ray subscribe manager -----
|
||||
class V2raySubscribe: NSObject {
|
||||
@ -222,4 +221,4 @@ class V2raySubItem: NSObject, NSCoding {
|
||||
static func remove(name: String) {
|
||||
UserDefaults.standard.removeObject(forKey: name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user