first commit

This commit is contained in:
yichengchen 2018-06-13 10:44:30 +08:00
commit 8f00a87903
24 changed files with 1526 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
Country.mmdb

View File

@ -0,0 +1,489 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objects = {
/* Begin PBXBuildFile section */
4989F98020D01C8F0001E564 /* clash.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4989F97E20D01C8F0001E564 /* clash.a */; };
4989F98420D02D200001E564 /* Country.mmdb in Resources */ = {isa = PBXBuildFile; fileRef = 4989F98320D02D200001E564 /* Country.mmdb */; };
4989F98B20D0AD800001E564 /* SampleConfigViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4989F98920D0AD800001E564 /* SampleConfigViewController.swift */; };
4989F98C20D0AD800001E564 /* SampleConfigViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4989F98A20D0AD800001E564 /* SampleConfigViewController.xib */; };
4989F98E20D0AE990001E564 /* sampleConfig.ini in Resources */ = {isa = PBXBuildFile; fileRef = 4989F98D20D0AE990001E564 /* sampleConfig.ini */; };
49CF3B2120CD7463001EBF94 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49CF3B2020CD7463001EBF94 /* AppDelegate.swift */; };
49CF3B2520CD7465001EBF94 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 49CF3B2420CD7465001EBF94 /* Assets.xcassets */; };
49CF3B2820CD7465001EBF94 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 49CF3B2620CD7465001EBF94 /* Main.storyboard */; };
49CF3B3F20CD7845001EBF94 /* menu_icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 49CF3B3B20CD7845001EBF94 /* menu_icon.png */; };
49CF3B4020CD7845001EBF94 /* menu_icon_disabled@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 49CF3B3C20CD7845001EBF94 /* menu_icon_disabled@2x.png */; };
49CF3B4120CD7845001EBF94 /* menu_icon_disabled.png in Resources */ = {isa = PBXBuildFile; fileRef = 49CF3B3D20CD7845001EBF94 /* menu_icon_disabled.png */; };
49CF3B4220CD7845001EBF94 /* menu_icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 49CF3B3E20CD7845001EBF94 /* menu_icon@2x.png */; };
49CF3B5C20CE8068001EBF94 /* ProxyConfigManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49CF3B5B20CE8068001EBF94 /* ProxyConfigManager.swift */; };
49CF3B5F20CE80D2001EBF94 /* install_proxy_helper.sh in Resources */ = {isa = PBXBuildFile; fileRef = 49CF3B5E20CE80D2001EBF94 /* install_proxy_helper.sh */; };
49CF3B6120CE8404001EBF94 /* ProxyConfig in Resources */ = {isa = PBXBuildFile; fileRef = 49CF3B6020CE8404001EBF94 /* ProxyConfig */; };
49CF3B6320CED9CF001EBF94 /* check_proxy_helper.sh in Resources */ = {isa = PBXBuildFile; fileRef = 49CF3B6220CED934001EBF94 /* check_proxy_helper.sh */; };
49CF3B6520CEE06C001EBF94 /* ConfigManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49CF3B6420CEE06C001EBF94 /* ConfigManager.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
49CF3B4F20CE5232001EBF94 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 49CF3B4B20CE5232001EBF94 /* ProxyConfig.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 36B6A3231E263590002B5B1D;
remoteInfo = ProxyConfig;
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
4989F97E20D01C8F0001E564 /* clash.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = clash.a; sourceTree = "<group>"; };
4989F97F20D01C8F0001E564 /* clash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = clash.h; sourceTree = "<group>"; };
4989F98320D02D200001E564 /* Country.mmdb */ = {isa = PBXFileReference; lastKnownFileType = file; path = Country.mmdb; sourceTree = "<group>"; };
4989F98920D0AD800001E564 /* SampleConfigViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SampleConfigViewController.swift; sourceTree = "<group>"; };
4989F98A20D0AD800001E564 /* SampleConfigViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SampleConfigViewController.xib; sourceTree = "<group>"; };
4989F98D20D0AE990001E564 /* sampleConfig.ini */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = sampleConfig.ini; sourceTree = "<group>"; };
49CF3B1D20CD7463001EBF94 /* ClashX.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ClashX.app; sourceTree = BUILT_PRODUCTS_DIR; };
49CF3B2020CD7463001EBF94 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
49CF3B2420CD7465001EBF94 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
49CF3B2720CD7465001EBF94 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
49CF3B2920CD7465001EBF94 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
49CF3B2A20CD7465001EBF94 /* ClashX.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ClashX.entitlements; sourceTree = "<group>"; };
49CF3B3520CD75DF001EBF94 /* ClashX-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ClashX-Bridging-Header.h"; sourceTree = "<group>"; };
49CF3B3B20CD7845001EBF94 /* menu_icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = menu_icon.png; sourceTree = "<group>"; };
49CF3B3C20CD7845001EBF94 /* menu_icon_disabled@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "menu_icon_disabled@2x.png"; sourceTree = "<group>"; };
49CF3B3D20CD7845001EBF94 /* menu_icon_disabled.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = menu_icon_disabled.png; sourceTree = "<group>"; };
49CF3B3E20CD7845001EBF94 /* menu_icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "menu_icon@2x.png"; sourceTree = "<group>"; };
49CF3B4B20CE5232001EBF94 /* ProxyConfig.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = ProxyConfig.xcodeproj; sourceTree = "<group>"; };
49CF3B5B20CE8068001EBF94 /* ProxyConfigManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProxyConfigManager.swift; sourceTree = "<group>"; };
49CF3B5E20CE80D2001EBF94 /* install_proxy_helper.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = install_proxy_helper.sh; sourceTree = "<group>"; };
49CF3B6020CE8404001EBF94 /* ProxyConfig */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; name = ProxyConfig; path = "../../../../../Library/Developer/Xcode/DerivedData/ClashX-bcbrsbofqgevdffhsbymjskmsxik/Build/Products/Debug/ProxyConfig"; sourceTree = "<group>"; };
49CF3B6220CED934001EBF94 /* check_proxy_helper.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = check_proxy_helper.sh; sourceTree = "<group>"; };
49CF3B6420CEE06C001EBF94 /* ConfigManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfigManager.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
49CF3B1A20CD7463001EBF94 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
4989F98020D01C8F0001E564 /* clash.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
4989F98520D0AA300001E564 /* ViewControllers */ = {
isa = PBXGroup;
children = (
4989F98920D0AD800001E564 /* SampleConfigViewController.swift */,
4989F98A20D0AD800001E564 /* SampleConfigViewController.xib */,
);
path = ViewControllers;
sourceTree = "<group>";
};
49CF3B1420CD7463001EBF94 = {
isa = PBXGroup;
children = (
49CF3B1F20CD7463001EBF94 /* ClashX */,
49CF3B1E20CD7463001EBF94 /* Products */,
);
sourceTree = "<group>";
};
49CF3B1E20CD7463001EBF94 /* Products */ = {
isa = PBXGroup;
children = (
49CF3B1D20CD7463001EBF94 /* ClashX.app */,
);
name = Products;
sourceTree = "<group>";
};
49CF3B1F20CD7463001EBF94 /* ClashX */ = {
isa = PBXGroup;
children = (
4989F98520D0AA300001E564 /* ViewControllers */,
49CF3B5D20CE80D2001EBF94 /* script */,
49CF3B5A20CE8054001EBF94 /* Managers */,
49CF3B4820CE5232001EBF94 /* ProxyConfig */,
49CF3B4320CD79A0001EBF94 /* clash */,
49CF3B3A20CD783A001EBF94 /* Support Files */,
49CF3B2020CD7463001EBF94 /* AppDelegate.swift */,
49CF3B2420CD7465001EBF94 /* Assets.xcassets */,
49CF3B2620CD7465001EBF94 /* Main.storyboard */,
49CF3B2920CD7465001EBF94 /* Info.plist */,
49CF3B2A20CD7465001EBF94 /* ClashX.entitlements */,
49CF3B3520CD75DF001EBF94 /* ClashX-Bridging-Header.h */,
);
path = ClashX;
sourceTree = "<group>";
};
49CF3B3A20CD783A001EBF94 /* Support Files */ = {
isa = PBXGroup;
children = (
4989F98D20D0AE990001E564 /* sampleConfig.ini */,
4989F98320D02D200001E564 /* Country.mmdb */,
49CF3B6020CE8404001EBF94 /* ProxyConfig */,
49CF3B3D20CD7845001EBF94 /* menu_icon_disabled.png */,
49CF3B3C20CD7845001EBF94 /* menu_icon_disabled@2x.png */,
49CF3B3B20CD7845001EBF94 /* menu_icon.png */,
49CF3B3E20CD7845001EBF94 /* menu_icon@2x.png */,
);
path = "Support Files";
sourceTree = "<group>";
};
49CF3B4320CD79A0001EBF94 /* clash */ = {
isa = PBXGroup;
children = (
4989F97E20D01C8F0001E564 /* clash.a */,
4989F97F20D01C8F0001E564 /* clash.h */,
);
path = clash;
sourceTree = "<group>";
};
49CF3B4820CE5232001EBF94 /* ProxyConfig */ = {
isa = PBXGroup;
children = (
49CF3B4B20CE5232001EBF94 /* ProxyConfig.xcodeproj */,
);
path = ProxyConfig;
sourceTree = "<group>";
};
49CF3B4C20CE5232001EBF94 /* Products */ = {
isa = PBXGroup;
children = (
49CF3B5020CE5232001EBF94 /* ProxyConfig */,
);
name = Products;
sourceTree = "<group>";
};
49CF3B5A20CE8054001EBF94 /* Managers */ = {
isa = PBXGroup;
children = (
49CF3B5B20CE8068001EBF94 /* ProxyConfigManager.swift */,
49CF3B6420CEE06C001EBF94 /* ConfigManager.swift */,
);
path = Managers;
sourceTree = "<group>";
};
49CF3B5D20CE80D2001EBF94 /* script */ = {
isa = PBXGroup;
children = (
49CF3B5E20CE80D2001EBF94 /* install_proxy_helper.sh */,
49CF3B6220CED934001EBF94 /* check_proxy_helper.sh */,
);
path = script;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
49CF3B1C20CD7463001EBF94 /* ClashX */ = {
isa = PBXNativeTarget;
buildConfigurationList = 49CF3B2D20CD7465001EBF94 /* Build configuration list for PBXNativeTarget "ClashX" */;
buildPhases = (
49CF3B1920CD7463001EBF94 /* Sources */,
49CF3B1A20CD7463001EBF94 /* Frameworks */,
49CF3B1B20CD7463001EBF94 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = ClashX;
productName = ClashX;
productReference = 49CF3B1D20CD7463001EBF94 /* ClashX.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
49CF3B1520CD7463001EBF94 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0940;
LastUpgradeCheck = 0940;
ORGANIZATIONNAME = west2online;
TargetAttributes = {
49CF3B1C20CD7463001EBF94 = {
CreatedOnToolsVersion = 9.4;
LastSwiftMigration = 0940;
SystemCapabilities = {
com.apple.Sandbox = {
enabled = 0;
};
};
};
};
};
buildConfigurationList = 49CF3B1820CD7463001EBF94 /* Build configuration list for PBXProject "ClashX" */;
compatibilityVersion = "Xcode 9.3";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 49CF3B1420CD7463001EBF94;
productRefGroup = 49CF3B1E20CD7463001EBF94 /* Products */;
projectDirPath = "";
projectReferences = (
{
ProductGroup = 49CF3B4C20CE5232001EBF94 /* Products */;
ProjectRef = 49CF3B4B20CE5232001EBF94 /* ProxyConfig.xcodeproj */;
},
);
projectRoot = "";
targets = (
49CF3B1C20CD7463001EBF94 /* ClashX */,
);
};
/* End PBXProject section */
/* Begin PBXReferenceProxy section */
49CF3B5020CE5232001EBF94 /* ProxyConfig */ = {
isa = PBXReferenceProxy;
fileType = "compiled.mach-o.executable";
path = ProxyConfig;
remoteRef = 49CF3B4F20CE5232001EBF94 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */
/* Begin PBXResourcesBuildPhase section */
49CF3B1B20CD7463001EBF94 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
49CF3B2520CD7465001EBF94 /* Assets.xcassets in Resources */,
49CF3B2820CD7465001EBF94 /* Main.storyboard in Resources */,
49CF3B4220CD7845001EBF94 /* menu_icon@2x.png in Resources */,
49CF3B6120CE8404001EBF94 /* ProxyConfig in Resources */,
49CF3B4120CD7845001EBF94 /* menu_icon_disabled.png in Resources */,
49CF3B5F20CE80D2001EBF94 /* install_proxy_helper.sh in Resources */,
49CF3B4020CD7845001EBF94 /* menu_icon_disabled@2x.png in Resources */,
49CF3B3F20CD7845001EBF94 /* menu_icon.png in Resources */,
4989F98420D02D200001E564 /* Country.mmdb in Resources */,
4989F98C20D0AD800001E564 /* SampleConfigViewController.xib in Resources */,
4989F98E20D0AE990001E564 /* sampleConfig.ini in Resources */,
49CF3B6320CED9CF001EBF94 /* check_proxy_helper.sh in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
49CF3B1920CD7463001EBF94 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4989F98B20D0AD800001E564 /* SampleConfigViewController.swift in Sources */,
49CF3B5C20CE8068001EBF94 /* ProxyConfigManager.swift in Sources */,
49CF3B2120CD7463001EBF94 /* AppDelegate.swift in Sources */,
49CF3B6520CEE06C001EBF94 /* ConfigManager.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
49CF3B2620CD7465001EBF94 /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
49CF3B2720CD7465001EBF94 /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
49CF3B2B20CD7465001EBF94 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "Mac Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
49CF3B2C20CD7465001EBF94 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "Mac Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
};
name = Release;
};
49CF3B2E20CD7465001EBF94 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = MEWHFZ92DY;
INFOPLIST_FILE = ClashX/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/ClashX",
"$(PROJECT_DIR)/ClashX/clash",
);
PRODUCT_BUNDLE_IDENTIFIER = com.west2online.ClashX;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "ClashX/ClashX-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
};
name = Debug;
};
49CF3B2F20CD7465001EBF94 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = MEWHFZ92DY;
INFOPLIST_FILE = ClashX/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/ClashX",
"$(PROJECT_DIR)/ClashX/clash",
);
PRODUCT_BUNDLE_IDENTIFIER = com.west2online.ClashX;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "ClashX/ClashX-Bridging-Header.h";
SWIFT_VERSION = 4.0;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
49CF3B1820CD7463001EBF94 /* Build configuration list for PBXProject "ClashX" */ = {
isa = XCConfigurationList;
buildConfigurations = (
49CF3B2B20CD7465001EBF94 /* Debug */,
49CF3B2C20CD7465001EBF94 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
49CF3B2D20CD7465001EBF94 /* Build configuration list for PBXNativeTarget "ClashX" */ = {
isa = XCConfigurationList;
buildConfigurations = (
49CF3B2E20CD7465001EBF94 /* Debug */,
49CF3B2F20CD7465001EBF94 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 49CF3B1520CD7463001EBF94 /* Project object */;
}

94
ClashX/AppDelegate.swift Normal file
View File

@ -0,0 +1,94 @@
//
// AppDelegate.swift
// ClashX
//
// Created by on 2018/6/10.
// Copyright © 2018 west2online. All rights reserved.
//
import Cocoa
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
var statusItem: NSStatusItem!
static let StatusItemIconWidth: CGFloat = NSStatusItem.variableLength
@IBOutlet weak var statusMenu: NSMenu!
@IBOutlet weak var proxySettingMenuItem: NSMenuItem!
let ssQueue = DispatchQueue(label: "com.w2fzu.ssqueue", attributes: .concurrent)
func applicationDidFinishLaunching(_ aNotification: Notification) {
// Insert code here to initialize your application
_ = ProxyConfigManager.install()
statusItem = NSStatusBar.system.statusItem(withLength: AppDelegate.StatusItemIconWidth)
let image : NSImage = NSImage(named: NSImage.Name(rawValue: "menu_icon"))!
image.isTemplate = true
statusItem.image = image
statusItem.menu = statusMenu
updateMenuItem()
startProxy()
}
func applicationWillTerminate(_ aNotification: Notification) {
if ConfigManager.proxyPortAutoSet {
_ = ProxyConfigManager.setUpSystemProxy(port: nil,socksPort: nil)
}
}
func updateMenuItem(){
proxySettingMenuItem.state = ConfigManager.proxyPortAutoSet ? .on : .off
}
func startProxy() {
ssQueue.async {
run()
}
let ports = getPortsC()
ConfigManager.httpProxyPort = Int(String(cString: ports.r0))!
ConfigManager.socksProxyPort = Int(String(cString: ports.r1))!
if ConfigManager.proxyPortAutoSet {
_ = ProxyConfigManager.setUpSystemProxy(port: ConfigManager.httpProxyPort,socksPort: ConfigManager.socksProxyPort)
}
}
@IBAction func actionQuit(_ sender: Any) {
NSApplication.shared.terminate(self)
}
@IBAction func actionSetSystemProxy(_ sender: Any) {
ConfigManager.proxyPortAutoSet = !ConfigManager.proxyPortAutoSet
updateMenuItem()
if ConfigManager.proxyPortAutoSet {
_ = ProxyConfigManager.setUpSystemProxy(port: ConfigManager.httpProxyPort,socksPort: ConfigManager.socksProxyPort)
} else {
_ = ProxyConfigManager.setUpSystemProxy(port: nil,socksPort: nil)
}
}
@IBAction func actionCopyExportCommand(_ sender: Any) {
let pasteboard = NSPasteboard.general
pasteboard.clearContents()
pasteboard.setString("export https_proxy=http://127.0.0.1:\(ConfigManager.httpProxyPort);export http_proxy=http://127.0.0.1:\(ConfigManager.httpProxyPort)", forType: .string)
}
@IBAction func openConfigFolder(_ sender: Any) {
let path = (NSHomeDirectory() as NSString).appendingPathComponent("/.config/clash/config.ini")
NSWorkspace.shared.openFile(path)
}
@IBAction func actionUpdateConfig(_ sender: Any) {
ssQueue.async {
updateConfigC()
}
}
}

View File

@ -0,0 +1,58 @@
{
"images" : [
{
"idiom" : "mac",
"size" : "16x16",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "16x16",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "32x32",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "32x32",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "128x128",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "128x128",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "256x256",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "256x256",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "512x512",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "512x512",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@ -0,0 +1,213 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14113"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Application-->
<scene sceneID="JPo-4y-FX3">
<objects>
<application id="hnw-xV-0zn" sceneMemberID="viewController">
<menu key="mainMenu" title="Main Menu" systemMenu="main" id="AYu-sK-qS6"/>
<connections>
<outlet property="delegate" destination="Voe-Tx-rLC" id="PrD-fu-P6m"/>
</connections>
</application>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="ClashX" customModuleProvider="target">
<connections>
<outlet property="proxySettingMenuItem" destination="8se-yr-wmp" id="yvm-QP-yoA"/>
<outlet property="statusMenu" destination="Afa-lD-EbR" id="cov-E9-WrO"/>
</connections>
</customObject>
<menu id="Afa-lD-EbR">
<items>
<menuItem title="set as system proxy" id="8se-yr-wmp">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="actionSetSystemProxy:" target="Voe-Tx-rLC" id="jrp-iz-ljC"/>
</connections>
</menuItem>
<menuItem title="start at login" id="B1J-XB-BiZ">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="copy export command" id="Jmb-PK-rMW">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="actionCopyExportCommand:" target="Voe-Tx-rLC" id="82r-sY-7xb"/>
</connections>
</menuItem>
<menuItem title="Config" id="JMV-Dy-CI0">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Config" id="tck-zU-JKQ">
<items>
<menuItem title="generate config" id="5Ab-VJ-iIm">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<segue destination="Byh-1P-5fs" kind="show" id="mVy-i5-se3"/>
</connections>
</menuItem>
<menuItem title="open Config Folder" id="DwE-WX-ETZ">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="openConfigFolder:" target="Voe-Tx-rLC" id="6Ke-Bi-AAZ"/>
</connections>
</menuItem>
<menuItem title="update config" id="q3G-VH-eyy">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="actionUpdateConfig:" target="Voe-Tx-rLC" id="oW5-Ll-SY8"/>
</connections>
</menuItem>
<menuItem title="import Config" id="GRE-Ra-Pkx">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="reload Config" id="MKB-4v-QNy">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="quit" id="NXU-86-Eem">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="actionQuit:" target="Voe-Tx-rLC" id="ZtA-Bb-6xk"/>
</connections>
</menuItem>
</items>
</menu>
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
<customObject id="Ady-hI-5gd" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="75" y="0.0"/>
</scene>
<!--Window Controller-->
<scene sceneID="seD-T7-5qr">
<objects>
<windowController id="Byh-1P-5fs" sceneMemberID="viewController">
<window key="window" title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" id="q8i-4q-6dO">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="294" y="313" width="480" height="270"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1057"/>
<connections>
<outlet property="delegate" destination="Byh-1P-5fs" id="pxR-Kp-c8L"/>
</connections>
</window>
<connections>
<segue destination="HdM-On-UrR" kind="relationship" relationship="window.shadowedContentViewController" id="nAQ-Yb-JTm"/>
</connections>
</windowController>
<customObject id="qnw-vI-E5o" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="678" y="10"/>
</scene>
<!--Sample Config Generator-->
<scene sceneID="BM0-mm-BUh">
<objects>
<viewController title="Sample Config Generator" id="HdM-On-UrR" customClass="SampleConfigViewController" customModule="ClashX" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" id="8rY-uh-JEl">
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ZHC-RX-R69">
<rect key="frame" x="106" y="198" width="71" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="服务器地址" id="D1f-Cw-42v">
<font key="font" usesAppearanceFont="YES"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="85H-oC-l4Y">
<rect key="frame" x="106" y="173" width="31" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="端口" id="TvM-SN-PIX">
<font key="font" usesAppearanceFont="YES"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="oFA-yE-6xN">
<rect key="frame" x="106" y="148" width="31" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="密码" id="Pnz-Id-ZXs">
<font key="font" usesAppearanceFont="YES"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="4XJ-Py-Gyq">
<rect key="frame" x="198" y="196" width="96" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="pQU-gt-i5v">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="trr-AX-8af">
<rect key="frame" x="106" y="123" width="58" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="加密方式" id="VCn-Oh-1Fg">
<font key="font" usesAppearanceFont="YES"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2ic-db-leA">
<rect key="frame" x="198" y="169" width="96" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="Zcf-6H-pVA">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<secureTextField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="qiG-Ou-jgy">
<rect key="frame" x="198" y="143" width="96" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<secureTextFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" usesSingleLineMode="YES" id="Hda-3T-qDm">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
<allowedInputSourceLocales>
<string>NSAllRomanInputSourcesLocaleIdentifier</string>
</allowedInputSourceLocales>
</secureTextFieldCell>
</secureTextField>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="OQp-TS-dYw">
<rect key="frame" x="374" y="13" width="78" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="确定" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="aOh-Mt-ZGu">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" usesAppearanceFont="YES"/>
</buttonCell>
<connections>
<action selector="actionConfirm:" target="HdM-On-UrR" id="Xj6-r6-juZ"/>
</connections>
</button>
<comboBox verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="MdP-r6-8PB">
<rect key="frame" x="198" y="116" width="139" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<comboBoxCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" completes="NO" numberOfVisibleItems="11" id="7yV-TN-Npa">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</comboBoxCell>
</comboBox>
</subviews>
</view>
<connections>
<outlet property="serverAddressTextField" destination="4XJ-Py-Gyq" id="XZr-UF-erL"/>
<outlet property="serverPasswordTextField" destination="qiG-Ou-jgy" id="zSO-58-ixh"/>
<outlet property="serverPortTextField" destination="2ic-db-leA" id="iW2-74-wKA"/>
<outlet property="serverencryptMethodBox" destination="MdP-r6-8PB" id="pgk-ff-azt"/>
</connections>
</viewController>
<customObject id="GXm-g7-KED" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1277" y="-1"/>
</scene>
</scenes>
</document>

View File

@ -0,0 +1,4 @@
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//
#import "clash.h"

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>

34
ClashX/Info.plist Normal file
View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>LSUIElement</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2018年 west2online. All rights reserved.</string>
<key>NSMainStoryboardFile</key>
<string>Main</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>

View File

@ -0,0 +1,44 @@
//
// ConfigManager.swift
// ClashX
//
// Created by on 2018/6/12.
// Copyright © 2018 west2online. All rights reserved.
//
import Foundation
import Cocoa
class ConfigManager {
private static let instance = ConfigManager()
var _httpProxyPort = 0
var _socksProxyPort = 0
static var proxyPortAutoSet:Bool {
get{
return UserDefaults.standard.bool(forKey: "proxyPortAutoSet")
}
set {
UserDefaults.standard.set(newValue, forKey: "proxyPortAutoSet")
}
}
static var httpProxyPort:Int {
get{
return instance._httpProxyPort
}
set {
instance._httpProxyPort = newValue
}
}
static var socksProxyPort:Int {
get{
return instance._socksProxyPort
}
set {
instance._socksProxyPort = newValue
}
}
}

View File

@ -0,0 +1,70 @@
import Foundation
class ProxyConfigManager {
static let kProxyConfigPath = (NSHomeDirectory() as NSString).appendingPathComponent("/.config/clash/")
static let kProxyHelperPath = "/Library/Application Support/clashX/ProxyConfig"
// static let kProxyConfigPath = Bundle.main.path(forResource: "ProxyConfig", ofType: nil)
static let kVersion = "0.4.0"
open static func checkVersion() -> Bool {
let scriptPath = "\(Bundle.main.resourcePath!)/check_proxy_helper.sh"
print(scriptPath)
let appleScriptStr = "do shell script \"bash \(scriptPath)\""
let appleScript = NSAppleScript(source: appleScriptStr)
var dict: NSDictionary?
if let res = appleScript?.executeAndReturnError(&dict) {
print(res.stringValue ?? "")
if (res.stringValue?.contains("root")) ?? false {
return true
}
}
return false
}
open static func install() -> Bool {
checkMMDB()
if !checkVersion() {
let scriptPath = "\(Bundle.main.resourcePath!)/install_proxy_helper.sh"
let appleScriptStr = "do shell script \"bash \(scriptPath)\" with administrator privileges"
let appleScript = NSAppleScript(source: appleScriptStr)
var dict: NSDictionary?
if let res = appleScript?.executeAndReturnError(&dict) {
print(res)
return true
} else {
return false
}
}
return true
}
static func checkMMDB() {
let fileManage = FileManager.default
let destMMDBPath = (NSHomeDirectory() as NSString).appendingPathComponent("/.config/clash/Country.mmdb")
if !fileManage.fileExists(atPath: destMMDBPath) {
let mmdbPath = Bundle.main.path(forResource: "Country", ofType: "mmdb")
try! fileManage.copyItem(at: URL(fileURLWithPath: mmdbPath!), to: URL(fileURLWithPath: destMMDBPath))
}
}
open static func setUpSystemProxy(port: Int?,socksPort: Int?) -> Bool {
let task = Process()
task.launchPath = kProxyHelperPath
if let port = port,let socksPort = socksPort {
task.arguments = [String(port),String(socksPort), "enable"]
} else {
task.arguments = ["0", "0", "disable"]
}
task.launch()
task.waitUntilExit()
if task.terminationStatus != 0 {
return false
}
return true
}
}

View File

@ -0,0 +1,257 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
36B6A3271E263590002B5B1D /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36B6A3261E263590002B5B1D /* main.swift */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
36B6A3211E263590002B5B1D /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = /usr/share/man/man1/;
dstSubfolderSpec = 0;
files = (
);
runOnlyForDeploymentPostprocessing = 1;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
36B6A3231E263590002B5B1D /* ProxyConfig */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ProxyConfig; sourceTree = BUILT_PRODUCTS_DIR; };
36B6A3261E263590002B5B1D /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
36B6A3201E263590002B5B1D /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
36B6A31A1E263590002B5B1D = {
isa = PBXGroup;
children = (
36B6A3251E263590002B5B1D /* ProxyConfig */,
36B6A3241E263590002B5B1D /* Products */,
);
sourceTree = "<group>";
};
36B6A3241E263590002B5B1D /* Products */ = {
isa = PBXGroup;
children = (
36B6A3231E263590002B5B1D /* ProxyConfig */,
);
name = Products;
sourceTree = "<group>";
};
36B6A3251E263590002B5B1D /* ProxyConfig */ = {
isa = PBXGroup;
children = (
36B6A3261E263590002B5B1D /* main.swift */,
);
path = ProxyConfig;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
36B6A3221E263590002B5B1D /* ProxyConfig */ = {
isa = PBXNativeTarget;
buildConfigurationList = 36B6A32A1E263590002B5B1D /* Build configuration list for PBXNativeTarget "ProxyConfig" */;
buildPhases = (
36B6A31F1E263590002B5B1D /* Sources */,
36B6A3201E263590002B5B1D /* Frameworks */,
36B6A3211E263590002B5B1D /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = ProxyConfig;
productName = ProxyConfig;
productReference = 36B6A3231E263590002B5B1D /* ProxyConfig */;
productType = "com.apple.product-type.tool";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
36B6A31B1E263590002B5B1D /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0820;
LastUpgradeCheck = 0820;
ORGANIZATIONNAME = "Zhuhao Wang";
TargetAttributes = {
36B6A3221E263590002B5B1D = {
CreatedOnToolsVersion = 8.2.1;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = 36B6A31E1E263590002B5B1D /* Build configuration list for PBXProject "ProxyConfig" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 36B6A31A1E263590002B5B1D;
productRefGroup = 36B6A3241E263590002B5B1D /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
36B6A3221E263590002B5B1D /* ProxyConfig */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
36B6A31F1E263590002B5B1D /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
36B6A3271E263590002B5B1D /* main.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
36B6A3281E263590002B5B1D /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
36B6A3291E263590002B5B1D /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
};
name = Release;
};
36B6A32B1E263590002B5B1D /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
36B6A32C1E263590002B5B1D /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
36B6A31E1E263590002B5B1D /* Build configuration list for PBXProject "ProxyConfig" */ = {
isa = XCConfigurationList;
buildConfigurations = (
36B6A3281E263590002B5B1D /* Debug */,
36B6A3291E263590002B5B1D /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
36B6A32A1E263590002B5B1D /* Build configuration list for PBXNativeTarget "ProxyConfig" */ = {
isa = XCConfigurationList;
buildConfigurations = (
36B6A32B1E263590002B5B1D /* Debug */,
36B6A32C1E263590002B5B1D /* Release */,
);
defaultConfigurationIsVisible = 0;
};
/* End XCConfigurationList section */
};
rootObject = 36B6A31B1E263590002B5B1D /* Project object */;
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:ProxyConfig.xcodeproj">
</FileRef>
</Workspace>

View File

@ -0,0 +1,98 @@
import Foundation
import SystemConfiguration
let version = "0.1.0"
func main(_ args: [String]) {
var port: Int = 0
var socksPort = 0
var flag: Bool = false
if args.count > 3 {
guard let _port = Int(args[1]),
let _socksPort = Int(args[2]) else {
print("ERROR: port is invalid.")
exit(EXIT_FAILURE)
}
guard args[3] == "enable" || args[3] == "disable" else {
print("ERROR: flag is invalid.")
exit(EXIT_FAILURE)
}
port = _port
socksPort = _socksPort
flag = args[3] == "enable"
} else if args.count == 2 {
if args[1] == "version" {
print(version)
exit(EXIT_SUCCESS)
}
} else {
print("Usage: ProxyConfig <port> <socksPort> <enable/disable>")
exit(EXIT_FAILURE)
}
var authRef: AuthorizationRef? = nil
let authFlags: AuthorizationFlags = [.extendRights, .interactionAllowed, .preAuthorize]
let authErr = AuthorizationCreate(nil, nil, authFlags, &authRef)
guard authErr == noErr else {
print("Error: Failed to create administration authorization due to error \(authErr).")
exit(EXIT_FAILURE)
}
guard authRef != nil else {
print("Error: No authorization has been granted to modify network configuration.")
exit(EXIT_FAILURE)
}
if let prefRef = SCPreferencesCreateWithAuthorization(nil, "ClashX" as CFString, nil, authRef),
let sets = SCPreferencesGetValue(prefRef, kSCPrefNetworkServices) {
for key in sets.allKeys {
let dict = sets.object(forKey: key) as? NSDictionary
let hardware = ((dict?["Interface"]) as? NSDictionary)?["Hardware"] as? String
if hardware == "AirPort" || hardware == "Ethernet" {
let ip = flag ? "127.0.0.1" : ""
let enableInt = flag ? 1 : 0
var proxySettings: [String:AnyObject] = [:]
proxySettings[kCFNetworkProxiesHTTPProxy as String] = ip as AnyObject
proxySettings[kCFNetworkProxiesHTTPEnable as String] = enableInt as AnyObject
proxySettings[kCFNetworkProxiesHTTPSProxy as String] = ip as AnyObject
proxySettings[kCFNetworkProxiesHTTPSEnable as String] = enableInt as AnyObject
proxySettings[kCFNetworkProxiesSOCKSProxy as String] = ip as AnyObject
proxySettings[kCFNetworkProxiesSOCKSEnable as String] = enableInt as AnyObject
if flag {
proxySettings[kCFNetworkProxiesHTTPPort as String] = port as AnyObject
proxySettings[kCFNetworkProxiesHTTPSPort as String] = port as AnyObject
proxySettings[kCFNetworkProxiesSOCKSPort as String] = port + 1 as AnyObject
} else {
proxySettings[kCFNetworkProxiesHTTPPort as String] = nil
proxySettings[kCFNetworkProxiesHTTPSPort as String] = nil
proxySettings[kCFNetworkProxiesSOCKSPort as String] = nil
}
proxySettings[kCFNetworkProxiesExceptionsList as String] = [
"192.168.0.0/16",
"10.0.0.0/8",
"172.16.0.0/12",
"127.0.0.1",
"localhost",
"*.local"
] as AnyObject
let path = "/\(kSCPrefNetworkServices)/\(key)/\(kSCEntNetProxies)"
SCPreferencesPathSetValue(prefRef, path as CFString, proxySettings as CFDictionary)
}
}
SCPreferencesCommitChanges(prefRef)
SCPreferencesApplyChanges(prefRef)
}
AuthorizationFree(authRef!, AuthorizationFlags())
exit(EXIT_SUCCESS)
}
main(CommandLine.arguments)

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 553 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 575 B

View File

@ -0,0 +1,14 @@
[General]
port = 7890
socks-port = 7891
[Proxy]
# name = ss, server, port, cipter, password
{{placeHolder}}
[Rule]
DOMAIN-SUFFIX,google.com,Proxy
DOMAIN-KEYWORD,google,Proxy
DOMAIN-SUFFIX,ad.com,REJECT
GEOIP,CN,DIRECT
FINAL,,Proxy

View File

@ -0,0 +1,27 @@
//
// ViewController.swift
// ClashX
//
// Created by on 2018/6/10.
// Copyright © 2018 west2online. All rights reserved.
//
import Cocoa
class ViewController: NSViewController {
override func viewDidLoad() {
super.viewDidLoad()
run()
// Do any additional setup after loading the view.
}
override var representedObject: Any? {
didSet {
// Update the view, if already loaded.
}
}
}

View File

@ -0,0 +1,74 @@
//
// SampleConfigViewController.swift
// ClashX
//
// Created by on 2018/6/13.
// Copyright © 2018 west2online. All rights reserved.
//
import Cocoa
class SampleConfigViewController: NSViewController {
@IBOutlet weak var serverAddressTextField: NSTextField!
@IBOutlet weak var serverPortTextField: NSTextField!
@IBOutlet weak var serverPasswordTextField: NSSecureTextField!
@IBOutlet weak var serverencryptMethodBox: NSComboBox!
override func viewDidLoad() {
super.viewDidLoad()
serverencryptMethodBox.addItems(withObjectValues: [
"AES-128-CTR",
"AES-192-CTR",
"AES-256-CTR",
"AES-128-CFB",
"AES-192-CFB",
"AES-256-CFB",
"CHACHA20-IETF",
"XCHACHA20",
"AEAD_AES_128_GCM",
"AEAD_AES_192_GCM",
"AEAD_AES_256_GCM",
"AEAD_CHACHA20_POLY1305"
])
}
func vaildConfig()->Bool {
if let port = Int(serverPortTextField.stringValue) {
if port > 0 && port <= 65535 {
return serverPortTextField.stringValue.count > 0 &&
serverPasswordTextField.stringValue.count > 0
}
}
return false
}
func generateConfig() {
let originalConfig = NSData(contentsOfFile: Bundle.main.path(forResource: "sampleConfig", ofType: "ini")!)
var configStr = String(data: originalConfig! as Data, encoding: .utf8)
let targetStr = "Proxy = ss, \(serverAddressTextField.stringValue), \(serverPortTextField.stringValue), \(serverencryptMethodBox.stringValue), \(serverPasswordTextField.stringValue)"
configStr = configStr?.replacingOccurrences(of: "{{placeHolder}}", with: targetStr)
// save to ~/.config/clash/config.ini
let path = (NSHomeDirectory() as NSString).appendingPathComponent("/.config/clash/config.ini")
if (FileManager.default.fileExists(atPath: path)) {
try? FileManager.default.removeItem(at: URL(fileURLWithPath: path))
}
try? configStr?.write(to: URL(fileURLWithPath: path), atomically: true, encoding: .utf8)
}
@IBAction func actionConfirm(_ sender: Any) {
if (vaildConfig()) {
generateConfig()
}
self.view.window?.windowController?.close()
}
}

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11134"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="SampleConfigViewController" customModuleProvider="target">
<connections>
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="Hz6-mo-xeY">
<rect key="frame" x="0.0" y="0.0" width="480" height="272"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
</customView>
</objects>
</document>

View File

@ -0,0 +1,6 @@
#!/bin/sh
cd "/Library/Application Support/clashX/ProxyConfig"
echo `ls -l ProxyConfig`

View File

@ -0,0 +1,6 @@
cd `dirname "${BASH_SOURCE[0]}"`
sudo mkdir -p "/Library/Application Support/clashX/"
sudo cp ProxyConfig "/Library/Application Support/clashX/"
sudo chown root:admin "/Library/Application Support/clashX/ProxyConfig"
sudo chmod +s "/Library/Application Support/clashX/ProxyConfig"
echo done