Skip to content

Commit

Permalink
Merge branch 'release/1.3.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
qiuyuzhou committed Nov 1, 2016
2 parents 713bcae + 381b9ce commit 9e231a7
Show file tree
Hide file tree
Showing 16 changed files with 100 additions and 103 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ Next Generation of [ShadowsocksX](https://github.com/shadowsocks/shadowsocks-iOS

## Why?

It's hard to maintain the original implement. There are too many unused code in it.
It also embed ss-local source. It's crazy to maintain depandences of ss-local.
So it's hard to update ss-local version.
It's hard to maintain the original implementation as there is too much unused code in it.
It also embeds the ss-local source. It's crazy to maintain dependencies of ss-local.
So it's hard to update the ss-local version.

Now I just copy the ss-local from home brew. Run ss-local executable as a Launch Agent in background.
Serve pac js file as a file url. So there are only some souce code related to GUI left.
Then I rewrite the GUI code by swift.
Now I just copied the ss-local from homebrew. Run ss-local executable as a Launch Agent in the background.
Serve PAC js file as a file URL. So there is only some source code related to GUI left.
Then I will rewrite the GUI code in Swift.

## Requirements

Expand All @@ -34,27 +34,27 @@ From [here](https://github.com/shadowsocks/ShadowsocksX-NG/releases/)
## Fetures

- Use ss-local from shadowsocks-libev 2.4.6
- Update PAC by download GFW List from github.
- Update PAC by download GFW List from GitHub.
- Show QRCode for current server profile.
- Scan QRCode from screen.
- Auto launch at login.
- User rules for PAC.
- Support OTA
- An advance preferences panel to configure:
- An advanced preferences panel to configure:
- Local socks5 listen address.
- Local socks5 listen port.
- Local socks5 timeout.
- If enable UDP relay.
- GFW List url.
- Manual spesify network service profiles which would be configure the proxy.
- GFW List URL.
- Manual specify network service profiles which would be configure the proxy.
- Could reorder shadowsocks profiles by drag & drop in servers preferences panel.

## Different from orignal ShadowsocksX

Run ss-local as backgroud service through launchd, not in app process.
So after you quit the app, the ss-local maybe is still running.
Run ss-local as a background service through launchd, not as an in-app process.
So after you quit the app, the ss-local maybe be still running.

Add a manual mode which won't configure the system proxy settings.
Added a manual mode which won't configure the system proxy settings.
Then you could configure your apps to use socks5 proxy manual.

## Contributing
Expand All @@ -69,5 +69,5 @@ ref: [GitFlow](http://nvie.com/posts/a-successful-git-branching-model/)

## License

The project is released under the terms of GPLv3.
The project is released under the terms of the GPLv3.

12 changes: 0 additions & 12 deletions ShadowsocksX-NG.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
9B3FFF291D08A1DF0019A709 /* user-rule.txt in Resources */ = {isa = PBXBuildFile; fileRef = 9B3FFF281D08A1DF0019A709 /* user-rule.txt */; };
9B3FFF321D08CEE40019A709 /* SWBQRCodeWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B3FFF311D08CEE40019A709 /* SWBQRCodeWindowController.m */; };
9B3FFF341D08CEF70019A709 /* SWBQRCodeWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9B3FFF331D08CEF70019A709 /* SWBQRCodeWindowController.xib */; };
9B3FFF381D08CF110019A709 /* jquery.min.js in Resources */ = {isa = PBXBuildFile; fileRef = 9B3FFF351D08CF110019A709 /* jquery.min.js */; };
9B3FFF391D08CF110019A709 /* qrcode.min.js in Resources */ = {isa = PBXBuildFile; fileRef = 9B3FFF361D08CF110019A709 /* qrcode.min.js */; };
9B3FFF3A1D08CF110019A709 /* qrcode.htm in Resources */ = {isa = PBXBuildFile; fileRef = 9B3FFF371D08CF110019A709 /* qrcode.htm */; };
9B3FFF3E1D08D9910019A709 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9B3FFF3D1D08D9910019A709 /* SystemConfiguration.framework */; };
9B3FFF471D09CD3B0019A709 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B3FFF461D09CD3B0019A709 /* main.m */; };
9B3FFF4C1D09D8F70019A709 /* install_helper.sh in Resources */ = {isa = PBXBuildFile; fileRef = 9B3FFF4B1D09D8F70019A709 /* install_helper.sh */; };
Expand Down Expand Up @@ -140,9 +137,6 @@
9B3FFF301D08CEE40019A709 /* SWBQRCodeWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SWBQRCodeWindowController.h; sourceTree = "<group>"; };
9B3FFF311D08CEE40019A709 /* SWBQRCodeWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SWBQRCodeWindowController.m; sourceTree = "<group>"; };
9B3FFF331D08CEF70019A709 /* SWBQRCodeWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SWBQRCodeWindowController.xib; sourceTree = "<group>"; };
9B3FFF351D08CF110019A709 /* jquery.min.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jquery.min.js; sourceTree = "<group>"; };
9B3FFF361D08CF110019A709 /* qrcode.min.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = qrcode.min.js; sourceTree = "<group>"; };
9B3FFF371D08CF110019A709 /* qrcode.htm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = qrcode.htm; sourceTree = "<group>"; };
9B3FFF3B1D08D93B0019A709 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
9B3FFF3D1D08D9910019A709 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
9B3FFF441D09CD3B0019A709 /* proxy_conf_helper */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = proxy_conf_helper; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -241,9 +235,6 @@
9BE8FBBD1D0B1FB900CAFD01 /* libcrypto.1.0.0.dylib */,
9B172A6C1D0ADDDD00B87B9A /* Localizable.strings */,
9B3FFF4B1D09D8F70019A709 /* install_helper.sh */,
9B3FFF351D08CF110019A709 /* jquery.min.js */,
9B3FFF361D08CF110019A709 /* qrcode.min.js */,
9B3FFF371D08CF110019A709 /* qrcode.htm */,
9B3FFF281D08A1DF0019A709 /* user-rule.txt */,
9B3FFF261D0898EB0019A709 /* gfwlist.txt */,
9B3FFF221D088E8D0019A709 /* abp.js */,
Expand Down Expand Up @@ -489,8 +480,6 @@
C6D429971DA75988002A5711 /* stop_privoxy.sh in Resources */,
C8E42A6E1D4F2CAF0074C7EA /* UserRulesController.xib in Resources */,
9BEEF06A1D04D4D500FC52B3 /* start_ss_local.sh in Resources */,
9B3FFF391D08CF110019A709 /* qrcode.min.js in Resources */,
9B3FFF3A1D08CF110019A709 /* qrcode.htm in Resources */,
C6D429941DA75988002A5711 /* privoxy in Resources */,
C6D429991DA76FBC002A5711 /* privoxy.config.example in Resources */,
9BEEF06B1D04D4D500FC52B3 /* stop_ss_local.sh in Resources */,
Expand All @@ -501,7 +490,6 @@
C6D429951DA75988002A5711 /* reload_conf_privoxy.sh in Resources */,
9B0BFFEB1D0460A70040E62B /* Assets.xcassets in Resources */,
9B2491B71D0ACC3E003BBECC /* AdvPreferencesWindowController.xib in Resources */,
9B3FFF381D08CF110019A709 /* jquery.min.js in Resources */,
9B3FFF271D0898EB0019A709 /* gfwlist.txt in Resources */,
C6D429931DA75988002A5711 /* install_privoxy.sh in Resources */,
9BC70EDC1D2E3E3100EDA4CA /* Localizable.strings in Resources */,
Expand Down
2 changes: 0 additions & 2 deletions ShadowsocksX-NG/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
StopSSLocal()
StopPrivoxy()
ProxyConfHelper.disableProxy()
let defaults = UserDefaults.standard
defaults.set(false, forKey: "ShadowsocksOn")
}

func applyConfig() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="Advance Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" animationBehavior="default" id="F0z-JX-Cv5">
<window title="Advanced Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" animationBehavior="default" id="F0z-JX-Cv5">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
<rect key="contentRect" x="562" y="415" width="480" height="345"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
Expand Down
14 changes: 11 additions & 3 deletions ShadowsocksX-NG/Base.lproj/HTTPPreferencesWindowController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<window title="HTTP Proxy Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" frameAutosaveName="" animationBehavior="default" id="vS3-DL-Nq3">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<rect key="contentRect" x="109" y="131" width="209" height="197"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1057"/>
<view key="contentView" id="Qef-Mj-9z1">
<rect key="frame" x="0.0" y="0.0" width="209" height="197"/>
<autoresizingMask key="autoresizingMask"/>
Expand Down Expand Up @@ -60,7 +60,11 @@
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<binding destination="Adn-6l-wm4" name="value" keyPath="values.LocalHTTP.ListenAddress" id="YV3-cX-xGk"/>
<binding destination="Adn-6l-wm4" name="value" keyPath="values.LocalHTTP.ListenAddress" id="TLb-4n-tsg">
<dictionary key="options">
<bool key="NSContinuouslyUpdatesValue" value="YES"/>
</dictionary>
</binding>
</connections>
</textField>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="lD1-xm-Qy3">
Expand All @@ -71,7 +75,11 @@
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<binding destination="Adn-6l-wm4" name="value" keyPath="values.LocalHTTP.ListenPort" id="URg-d3-2U6"/>
<binding destination="Adn-6l-wm4" name="value" keyPath="values.LocalHTTP.ListenPort" id="bVc-jE-7Ve">
<dictionary key="options">
<bool key="NSContinuouslyUpdatesValue" value="YES"/>
</dictionary>
</binding>
<outlet property="formatter" destination="ji3-e7-HNW" id="xWV-vJ-7eq"/>
</connections>
</textField>
Expand Down
8 changes: 4 additions & 4 deletions ShadowsocksX-NG/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="bMX-qn-Qwi"/>
<menuItem title="Show Running Mode On Status Bar" id="CCV-hX-fVA">
<menuItem title="Show Running Mode In Status Bar" id="CCV-hX-fVA">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="showRunningMode:" target="Voe-Tx-rLC" id="PxO-ut-PEx"/>
</connections>
</menuItem>
<menuItem title="Advance Proxy Preference..." id="sbx-yz-3lO">
<menuItem title="Advanced Proxy Preferences..." id="sbx-yz-3lO">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="editProxyPreferences:" target="Voe-Tx-rLC" id="Jji-Ea-Sy8"/>
Expand Down Expand Up @@ -120,13 +120,13 @@
</items>
</menu>
</menuItem>
<menuItem title="Advance Preference ..." id="bZ3-fy-34d">
<menuItem title="Advanced Preferences ..." id="bZ3-fy-34d">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="editAdvPreferences:" target="Voe-Tx-rLC" id="mEF-XS-HJE"/>
</connections>
</menuItem>
<menuItem title="HTTP Proxy Preference ..." id="uEp-Gz-cu0">
<menuItem title="HTTP Proxy Preferences ..." id="uEp-Gz-cu0">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="editHTTPPreferences:" target="Voe-Tx-rLC" id="tkC-e3-PH9"/>
Expand Down
2 changes: 1 addition & 1 deletion ShadowsocksX-NG/Base.lproj/ProxyPreferencesController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="Advance Proxy Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" animationBehavior="default" id="F0z-JX-Cv5">
<window title="Advanced Proxy Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" animationBehavior="default" id="F0z-JX-Cv5">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<rect key="contentRect" x="503" y="308" width="298" height="311"/>
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/>
Expand Down
2 changes: 1 addition & 1 deletion ShadowsocksX-NG/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.3.1</string>
<string>1.3.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand Down
14 changes: 8 additions & 6 deletions ShadowsocksX-NG/ProxyConfHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,14 @@ + (void)enableGlobalProxy {
NSMutableArray* args = [@[@"--mode", @"global", @"--port"
, [NSString stringWithFormat:@"%lu", (unsigned long)port]]mutableCopy];

if ([[NSUserDefaults standardUserDefaults] boolForKey:@"LocalHTTPOn"] && [[NSUserDefaults standardUserDefaults] boolForKey:@"LocalHTTP.FollowGlobel"]) {
NSUInteger privoxyPort = [[NSUserDefaults standardUserDefaults]integerForKey:@"LocalHTTP.ListenPort"];

[args addObject:@"--privoxy-port"];
[args addObject:[NSString stringWithFormat:@"%lu", (unsigned long)privoxyPort]];
}
// Because issue #106 https://github.com/shadowsocks/ShadowsocksX-NG/issues/106
// Comment below out.
// if ([[NSUserDefaults standardUserDefaults] boolForKey:@"LocalHTTPOn"] && [[NSUserDefaults standardUserDefaults] boolForKey:@"LocalHTTP.FollowGlobel"]) {
// NSUInteger privoxyPort = [[NSUserDefaults standardUserDefaults]integerForKey:@"LocalHTTP.ListenPort"];
//
// [args addObject:@"--privoxy-port"];
// [args addObject:[NSString stringWithFormat:@"%lu", (unsigned long)privoxyPort]];
// }

[self addArguments4ManualSpecifyNetworkServices:args];
[self callHelper:args];
Expand Down
4 changes: 2 additions & 2 deletions ShadowsocksX-NG/SWBQRCodeWindowController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>

@interface SWBQRCodeWindowController : NSWindowController <WebFrameLoadDelegate>
@interface SWBQRCodeWindowController : NSWindowController

@property (nonatomic, strong) IBOutlet WebView *webView;
@property (nonatomic, copy) NSString *qrCode;
@property (nonatomic, weak) NSImageView *imageView;

@end
55 changes: 47 additions & 8 deletions ShadowsocksX-NG/SWBQRCodeWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

#import "SWBQRCodeWindowController.h"
@import CoreImage;

@interface SWBQRCodeWindowController ()

Expand All @@ -18,18 +19,56 @@ - (void)windowDidLoad {
[super windowDidLoad];

// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
[self.webView.mainFrame loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"qrcode" withExtension:@"htm"]]];
self.webView.frameLoadDelegate = self;
[self setQRCode:self.qrCode];
}

-(void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
if (self.qrCode) {
[self.webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"genCode('%@')", _qrCode]];
}
- (void)setQRCode:(NSString*) qrCode {
CGImageRef cgImgRef = [self createQRImageForString:qrCode size:CGSizeMake(250, 250)];

NSImage *image = [[NSImage alloc]initWithCGImage:cgImgRef size:CGSizeMake(250, 250)];
self.imageView.image = image;
}

-(void)dealloc {
self.webView.frameLoadDelegate = nil;
- (CGImageRef)createQRImageForString:(NSString *)string size:(CGSize)size {
// Setup the QR filter with our string
CIFilter *filter = [CIFilter filterWithName:@"CIQRCodeGenerator"];
[filter setDefaults];

NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
[filter setValue:data forKey:@"inputMessage"];
CIImage *image = [filter valueForKey:@"outputImage"];

// Calculate the size of the generated image and the scale for the desired image size
CGRect extent = CGRectIntegral(image.extent);
CGFloat scale = MIN(size.width / CGRectGetWidth(extent), size.height / CGRectGetHeight(extent));

// Since CoreImage nicely interpolates, we need to create a bitmap image that we'll draw into
// a bitmap context at the desired size;
size_t width = CGRectGetWidth(extent) * scale;
size_t height = CGRectGetHeight(extent) * scale;
CGColorSpaceRef cs = CGColorSpaceCreateDeviceGray();
CGContextRef bitmapRef = CGBitmapContextCreate(nil, width, height, 8, 0, cs, (CGBitmapInfo)kCGImageAlphaNone);

#if TARGET_OS_IPHONE
CIContext *context = [CIContext contextWithOptions:nil];
#else
CIContext *context = [CIContext contextWithCGContext:bitmapRef options:nil];
#endif

CGImageRef bitmapImage = [context createCGImage:image fromRect:extent];

CGContextSetInterpolationQuality(bitmapRef, kCGInterpolationNone);
CGContextScaleCTM(bitmapRef, scale, scale);
CGContextDrawImage(bitmapRef, extent, bitmapImage);

// Create an image with the contents of our bitmap
CGImageRef scaledImage = CGBitmapContextCreateImage(bitmapRef);

// Cleanup
CGContextRelease(bitmapRef);
CGImageRelease(bitmapImage);

return scaledImage;
}

@end
Loading

0 comments on commit 9e231a7

Please sign in to comment.