Merge pull request #1001 from lkebin/add-v2ray-plugin

Add v2ray-plugin
This commit is contained in:
Kebin Liu
2019-02-21 16:25:48 +08:00
committed by GitHub
6 changed files with 67 additions and 7 deletions

View File

@ -77,6 +77,8 @@
9BEEF0701D04DDB100FC52B3 /* ServerProfileManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BEEF06F1D04DDB100FC52B3 /* ServerProfileManager.swift */; };
9BEEF0751D04EF3E00FC52B3 /* PreferencesWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BEEF0731D04EF3E00FC52B3 /* PreferencesWindowController.swift */; };
9BEEF0781D04FE8A00FC52B3 /* LaunchAgentUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BEEF0771D04FE8A00FC52B3 /* LaunchAgentUtils.swift */; };
B5A2AB03221A72EC003F77B7 /* v2ray-plugin in Resources */ = {isa = PBXBuildFile; fileRef = B5A2AB01221A72EC003F77B7 /* v2ray-plugin */; };
B5A2AB04221A72EC003F77B7 /* install_v2ray_plugin.sh in Resources */ = {isa = PBXBuildFile; fileRef = B5A2AB02221A72EC003F77B7 /* install_v2ray_plugin.sh */; };
C6D429931DA75988002A5711 /* install_privoxy.sh in Resources */ = {isa = PBXBuildFile; fileRef = C6D4298E1DA75988002A5711 /* install_privoxy.sh */; };
C6D429941DA75988002A5711 /* privoxy in Resources */ = {isa = PBXBuildFile; fileRef = C6D4298F1DA75988002A5711 /* privoxy */; };
C6D429961DA75988002A5711 /* start_privoxy.sh in Resources */ = {isa = PBXBuildFile; fileRef = C6D429911DA75988002A5711 /* start_privoxy.sh */; };
@ -236,6 +238,8 @@
9BEEF0731D04EF3E00FC52B3 /* PreferencesWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PreferencesWindowController.swift; sourceTree = "<group>"; };
9BEEF0771D04FE8A00FC52B3 /* LaunchAgentUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LaunchAgentUtils.swift; sourceTree = "<group>"; };
B4E6A97CA843F3943524B686 /* Pods-proxy_conf_helper.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-proxy_conf_helper.debug.xcconfig"; path = "Pods/Target Support Files/Pods-proxy_conf_helper/Pods-proxy_conf_helper.debug.xcconfig"; sourceTree = "<group>"; };
B5A2AB01221A72EC003F77B7 /* v2ray-plugin */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = "v2ray-plugin"; sourceTree = "<group>"; };
B5A2AB02221A72EC003F77B7 /* install_v2ray_plugin.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = install_v2ray_plugin.sh; sourceTree = "<group>"; };
C6D4298E1DA75988002A5711 /* install_privoxy.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = install_privoxy.sh; sourceTree = "<group>"; };
C6D4298F1DA75988002A5711 /* privoxy */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = privoxy; sourceTree = "<group>"; };
C6D429911DA75988002A5711 /* start_privoxy.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = start_privoxy.sh; sourceTree = "<group>"; };
@ -306,6 +310,7 @@
9B07EFB01D048E900052D9DF /* Support Files */ = {
isa = PBXGroup;
children = (
B5A2AB00221A72EC003F77B7 /* v2ray-plugin */,
9B5D13252154A4B400F99F03 /* kcptun */,
9B5AA0A9209C41EC00E8B659 /* ss-local */,
1C82DBA31FA96C7400B32551 /* simple-obfs */,
@ -480,6 +485,15 @@
name = Products;
sourceTree = "<group>";
};
B5A2AB00221A72EC003F77B7 /* v2ray-plugin */ = {
isa = PBXGroup;
children = (
B5A2AB01221A72EC003F77B7 /* v2ray-plugin */,
B5A2AB02221A72EC003F77B7 /* install_v2ray_plugin.sh */,
);
path = "v2ray-plugin";
sourceTree = "<group>";
};
D3CE66CC039F651F28057DDB /* Frameworks */ = {
isa = PBXGroup;
children = (
@ -635,6 +649,7 @@
9B938D9A1E864B38005F5636 /* menu_g_icon@2x.png in Resources */,
9B938D9E1E864B38005F5636 /* menu_p_icon@2x.png in Resources */,
9B9CBCAF1E263B1600FC61AA /* libpcre.1.dylib in Resources */,
B5A2AB03221A72EC003F77B7 /* v2ray-plugin in Resources */,
9B5832031E741F8D009D5B7D /* command-512.png in Resources */,
9B3FFF541D09E2D10019A709 /* proxy_conf_helper in Resources */,
9B5832071E7421B2009D5B7D /* virtual-server-icon-3.png in Resources */,
@ -656,6 +671,7 @@
9BAFE2E21E83ED7F00F71CCE /* PreferencesWinController.xib in Resources */,
9B0BFFEB1D0460A70040E62B /* Assets.xcassets in Resources */,
08FCA0FF1E24BE1A0070984F /* example-gui-config.json in Resources */,
B5A2AB04221A72EC003F77B7 /* install_v2ray_plugin.sh in Resources */,
9B5D13292154A57C00F99F03 /* kcptun_client in Resources */,
1C82DBA81FA96C7500B32551 /* obfs-local in Resources */,
9B938D9D1E864B38005F5636 /* menu_p_icon.png in Resources */,

View File

@ -84,6 +84,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
InstallPrivoxy()
InstallSimpleObfs()
InstallKcptun()
InstallV2rayPlugin()
// Prepare defaults
let defaults = UserDefaults.standard

View File

@ -10,6 +10,7 @@ import Foundation
let SS_LOCAL_VERSION = "3.1.3"
let KCPTUN_CLIENT_VERSION = "v20170718"
let V2RAY_PLUGIN_VERSION = "master"
let PRIVOXY_VERSION = "3.0.26.static"
let SIMPLE_OBFS_VERSION = "0.0.5_1"
let APP_SUPPORT_DIR = "/Library/Application Support/ShadowsocksX-NG/"
@ -230,6 +231,26 @@ func InstallKcptun() {
}
}
// --------------------------------------------------------------------------------
// MARK: v2ray-plugin
func InstallV2rayPlugin() {
let fileMgr = FileManager.default
let homeDir = NSHomeDirectory()
let appSupportDir = homeDir+APP_SUPPORT_DIR
if !fileMgr.fileExists(atPath: appSupportDir + "v2ray-plugin_\(V2RAY_PLUGIN_VERSION)/v2ray-plugin") {
let bundle = Bundle.main
let installerPath = bundle.path(forResource: "install_v2ray_plugin", ofType: "sh")
let task = Process.launchedProcess(launchPath: "/bin/sh", arguments: [installerPath!])
task.waitUntilExit()
if task.terminationStatus == 0 {
NSLog("Install v2ray-plugin succeeded.")
} else {
NSLog("Install v2ray-plugin failed.")
}
}
}
// --------------------------------------------------------------------------------
// MARK: privoxy

View File

@ -245,13 +245,16 @@ GCDWebServer *webServer =nil;
if(flags & DISPATCH_VNODE_DELETE)
{
dispatch_source_cancel(source);
} else {
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
if ([defaults boolForKey:@"ShadowsocksOn"]) {
if ([[defaults stringForKey:@"ShadowsocksRunningMode"] isEqualToString:@"auto"]) {
[ProxyConfHelper disableProxy];
[ProxyConfHelper enablePACProxy];
}
}
// The PAC file was written by atomically (PACUtils.swift:134)
// That means DISPATCH_VNODE_DELETE event always be trigged
// Need to be run the following statements in any events
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
if ([defaults boolForKey:@"ShadowsocksOn"]) {
if ([[defaults stringForKey:@"ShadowsocksRunningMode"] isEqualToString:@"auto"]) {
[ProxyConfHelper disableProxy];
[ProxyConfHelper enablePACProxy];
}
}
});

View File

@ -0,0 +1,19 @@
#!/bin/sh
# install_v2ray_plugin.sh
# ShadowsocksX-NG
#
# Created by lkebin on 2019/2/18.
# Copyright © 2019 qiuyuzhou. All rights reserved.
# https://github.com/shadowsocks/v2ray-plugin/tree/master
VERSION="master"
cd `dirname "${BASH_SOURCE[0]}"`
mkdir -p "$HOME/Library/Application Support/ShadowsocksX-NG/v2ray-plugin_$VERSION"
cp -f v2ray-plugin "$HOME/Library/Application Support/ShadowsocksX-NG/v2ray-plugin_$VERSION/"
ln -sfh "$HOME/Library/Application Support/ShadowsocksX-NG/v2ray-plugin_$VERSION/v2ray-plugin" "$HOME/Library/Application Support/ShadowsocksX-NG/plugins/v2ray-plugin"
echo "install v2ray-plugin done"

Binary file not shown.