Skip to content

Commit 9e231a7

Browse files
committed
Merge branch 'release/1.3.2'
2 parents 713bcae + 381b9ce commit 9e231a7

16 files changed

+100
-103
lines changed

README.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ Next Generation of [ShadowsocksX](https://github.com/shadowsocks/shadowsocks-iOS
88

99
## Why?
1010

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

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

1919
## Requirements
2020

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

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

5252
## Different from orignal ShadowsocksX
5353

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

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

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

7070
## License
7171

72-
The project is released under the terms of GPLv3.
72+
The project is released under the terms of the GPLv3.
7373

ShadowsocksX-NG.xcodeproj/project.pbxproj

-12
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
9B3FFF291D08A1DF0019A709 /* user-rule.txt in Resources */ = {isa = PBXBuildFile; fileRef = 9B3FFF281D08A1DF0019A709 /* user-rule.txt */; };
3131
9B3FFF321D08CEE40019A709 /* SWBQRCodeWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B3FFF311D08CEE40019A709 /* SWBQRCodeWindowController.m */; };
3232
9B3FFF341D08CEF70019A709 /* SWBQRCodeWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9B3FFF331D08CEF70019A709 /* SWBQRCodeWindowController.xib */; };
33-
9B3FFF381D08CF110019A709 /* jquery.min.js in Resources */ = {isa = PBXBuildFile; fileRef = 9B3FFF351D08CF110019A709 /* jquery.min.js */; };
34-
9B3FFF391D08CF110019A709 /* qrcode.min.js in Resources */ = {isa = PBXBuildFile; fileRef = 9B3FFF361D08CF110019A709 /* qrcode.min.js */; };
35-
9B3FFF3A1D08CF110019A709 /* qrcode.htm in Resources */ = {isa = PBXBuildFile; fileRef = 9B3FFF371D08CF110019A709 /* qrcode.htm */; };
3633
9B3FFF3E1D08D9910019A709 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9B3FFF3D1D08D9910019A709 /* SystemConfiguration.framework */; };
3734
9B3FFF471D09CD3B0019A709 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B3FFF461D09CD3B0019A709 /* main.m */; };
3835
9B3FFF4C1D09D8F70019A709 /* install_helper.sh in Resources */ = {isa = PBXBuildFile; fileRef = 9B3FFF4B1D09D8F70019A709 /* install_helper.sh */; };
@@ -140,9 +137,6 @@
140137
9B3FFF301D08CEE40019A709 /* SWBQRCodeWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SWBQRCodeWindowController.h; sourceTree = "<group>"; };
141138
9B3FFF311D08CEE40019A709 /* SWBQRCodeWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SWBQRCodeWindowController.m; sourceTree = "<group>"; };
142139
9B3FFF331D08CEF70019A709 /* SWBQRCodeWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SWBQRCodeWindowController.xib; sourceTree = "<group>"; };
143-
9B3FFF351D08CF110019A709 /* jquery.min.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jquery.min.js; sourceTree = "<group>"; };
144-
9B3FFF361D08CF110019A709 /* qrcode.min.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = qrcode.min.js; sourceTree = "<group>"; };
145-
9B3FFF371D08CF110019A709 /* qrcode.htm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = qrcode.htm; sourceTree = "<group>"; };
146140
9B3FFF3B1D08D93B0019A709 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
147141
9B3FFF3D1D08D9910019A709 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
148142
9B3FFF441D09CD3B0019A709 /* proxy_conf_helper */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = proxy_conf_helper; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -241,9 +235,6 @@
241235
9BE8FBBD1D0B1FB900CAFD01 /* libcrypto.1.0.0.dylib */,
242236
9B172A6C1D0ADDDD00B87B9A /* Localizable.strings */,
243237
9B3FFF4B1D09D8F70019A709 /* install_helper.sh */,
244-
9B3FFF351D08CF110019A709 /* jquery.min.js */,
245-
9B3FFF361D08CF110019A709 /* qrcode.min.js */,
246-
9B3FFF371D08CF110019A709 /* qrcode.htm */,
247238
9B3FFF281D08A1DF0019A709 /* user-rule.txt */,
248239
9B3FFF261D0898EB0019A709 /* gfwlist.txt */,
249240
9B3FFF221D088E8D0019A709 /* abp.js */,
@@ -489,8 +480,6 @@
489480
C6D429971DA75988002A5711 /* stop_privoxy.sh in Resources */,
490481
C8E42A6E1D4F2CAF0074C7EA /* UserRulesController.xib in Resources */,
491482
9BEEF06A1D04D4D500FC52B3 /* start_ss_local.sh in Resources */,
492-
9B3FFF391D08CF110019A709 /* qrcode.min.js in Resources */,
493-
9B3FFF3A1D08CF110019A709 /* qrcode.htm in Resources */,
494483
C6D429941DA75988002A5711 /* privoxy in Resources */,
495484
C6D429991DA76FBC002A5711 /* privoxy.config.example in Resources */,
496485
9BEEF06B1D04D4D500FC52B3 /* stop_ss_local.sh in Resources */,
@@ -501,7 +490,6 @@
501490
C6D429951DA75988002A5711 /* reload_conf_privoxy.sh in Resources */,
502491
9B0BFFEB1D0460A70040E62B /* Assets.xcassets in Resources */,
503492
9B2491B71D0ACC3E003BBECC /* AdvPreferencesWindowController.xib in Resources */,
504-
9B3FFF381D08CF110019A709 /* jquery.min.js in Resources */,
505493
9B3FFF271D0898EB0019A709 /* gfwlist.txt in Resources */,
506494
C6D429931DA75988002A5711 /* install_privoxy.sh in Resources */,
507495
9BC70EDC1D2E3E3100EDA4CA /* Localizable.strings in Resources */,

ShadowsocksX-NG/AppDelegate.swift

-2
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
172172
StopSSLocal()
173173
StopPrivoxy()
174174
ProxyConfHelper.disableProxy()
175-
let defaults = UserDefaults.standard
176-
defaults.set(false, forKey: "ShadowsocksOn")
177175
}
178176

179177
func applyConfig() {

ShadowsocksX-NG/Base.lproj/AdvPreferencesWindowController.xib

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</customObject>
1313
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
1414
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
15-
<window title="Advance Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" animationBehavior="default" id="F0z-JX-Cv5">
15+
<window title="Advanced Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" animationBehavior="default" id="F0z-JX-Cv5">
1616
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
1717
<rect key="contentRect" x="562" y="415" width="480" height="345"/>
1818
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>

ShadowsocksX-NG/Base.lproj/HTTPPreferencesWindowController.xib

+11-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<window title="HTTP Proxy Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" frameAutosaveName="" animationBehavior="default" id="vS3-DL-Nq3">
1212
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
1313
<rect key="contentRect" x="109" y="131" width="209" height="197"/>
14-
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
14+
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1057"/>
1515
<view key="contentView" id="Qef-Mj-9z1">
1616
<rect key="frame" x="0.0" y="0.0" width="209" height="197"/>
1717
<autoresizingMask key="autoresizingMask"/>
@@ -60,7 +60,11 @@
6060
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
6161
</textFieldCell>
6262
<connections>
63-
<binding destination="Adn-6l-wm4" name="value" keyPath="values.LocalHTTP.ListenAddress" id="YV3-cX-xGk"/>
63+
<binding destination="Adn-6l-wm4" name="value" keyPath="values.LocalHTTP.ListenAddress" id="TLb-4n-tsg">
64+
<dictionary key="options">
65+
<bool key="NSContinuouslyUpdatesValue" value="YES"/>
66+
</dictionary>
67+
</binding>
6468
</connections>
6569
</textField>
6670
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="lD1-xm-Qy3">
@@ -71,7 +75,11 @@
7175
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
7276
</textFieldCell>
7377
<connections>
74-
<binding destination="Adn-6l-wm4" name="value" keyPath="values.LocalHTTP.ListenPort" id="URg-d3-2U6"/>
78+
<binding destination="Adn-6l-wm4" name="value" keyPath="values.LocalHTTP.ListenPort" id="bVc-jE-7Ve">
79+
<dictionary key="options">
80+
<bool key="NSContinuouslyUpdatesValue" value="YES"/>
81+
</dictionary>
82+
</binding>
7583
<outlet property="formatter" destination="ji3-e7-HNW" id="xWV-vJ-7eq"/>
7684
</connections>
7785
</textField>

ShadowsocksX-NG/Base.lproj/MainMenu.xib

+4-4
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@
7979
</connections>
8080
</menuItem>
8181
<menuItem isSeparatorItem="YES" id="bMX-qn-Qwi"/>
82-
<menuItem title="Show Running Mode On Status Bar" id="CCV-hX-fVA">
82+
<menuItem title="Show Running Mode In Status Bar" id="CCV-hX-fVA">
8383
<modifierMask key="keyEquivalentModifierMask"/>
8484
<connections>
8585
<action selector="showRunningMode:" target="Voe-Tx-rLC" id="PxO-ut-PEx"/>
8686
</connections>
8787
</menuItem>
88-
<menuItem title="Advance Proxy Preference..." id="sbx-yz-3lO">
88+
<menuItem title="Advanced Proxy Preferences..." id="sbx-yz-3lO">
8989
<modifierMask key="keyEquivalentModifierMask"/>
9090
<connections>
9191
<action selector="editProxyPreferences:" target="Voe-Tx-rLC" id="Jji-Ea-Sy8"/>
@@ -120,13 +120,13 @@
120120
</items>
121121
</menu>
122122
</menuItem>
123-
<menuItem title="Advance Preference ..." id="bZ3-fy-34d">
123+
<menuItem title="Advanced Preferences ..." id="bZ3-fy-34d">
124124
<modifierMask key="keyEquivalentModifierMask"/>
125125
<connections>
126126
<action selector="editAdvPreferences:" target="Voe-Tx-rLC" id="mEF-XS-HJE"/>
127127
</connections>
128128
</menuItem>
129-
<menuItem title="HTTP Proxy Preference ..." id="uEp-Gz-cu0">
129+
<menuItem title="HTTP Proxy Preferences ..." id="uEp-Gz-cu0">
130130
<modifierMask key="keyEquivalentModifierMask"/>
131131
<connections>
132132
<action selector="editHTTPPreferences:" target="Voe-Tx-rLC" id="tkC-e3-PH9"/>

ShadowsocksX-NG/Base.lproj/ProxyPreferencesController.xib

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</customObject>
1414
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
1515
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
16-
<window title="Advance Proxy Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" animationBehavior="default" id="F0z-JX-Cv5">
16+
<window title="Advanced Proxy Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" animationBehavior="default" id="F0z-JX-Cv5">
1717
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
1818
<rect key="contentRect" x="503" y="308" width="298" height="311"/>
1919
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/>

ShadowsocksX-NG/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<key>CFBundlePackageType</key>
1818
<string>APPL</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>1.3.1</string>
20+
<string>1.3.2</string>
2121
<key>CFBundleSignature</key>
2222
<string>????</string>
2323
<key>CFBundleURLTypes</key>

ShadowsocksX-NG/ProxyConfHelper.m

+8-6
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,14 @@ + (void)enableGlobalProxy {
139139
NSMutableArray* args = [@[@"--mode", @"global", @"--port"
140140
, [NSString stringWithFormat:@"%lu", (unsigned long)port]]mutableCopy];
141141

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

149151
[self addArguments4ManualSpecifyNetworkServices:args];
150152
[self callHelper:args];

ShadowsocksX-NG/SWBQRCodeWindowController.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
#import <Cocoa/Cocoa.h>
1010
#import <WebKit/WebKit.h>
1111

12-
@interface SWBQRCodeWindowController : NSWindowController <WebFrameLoadDelegate>
12+
@interface SWBQRCodeWindowController : NSWindowController
1313

14-
@property (nonatomic, strong) IBOutlet WebView *webView;
1514
@property (nonatomic, copy) NSString *qrCode;
15+
@property (nonatomic, weak) NSImageView *imageView;
1616

1717
@end

ShadowsocksX-NG/SWBQRCodeWindowController.m

+47-8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
#import "SWBQRCodeWindowController.h"
10+
@import CoreImage;
1011

1112
@interface SWBQRCodeWindowController ()
1213

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

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

25-
-(void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
26-
if (self.qrCode) {
27-
[self.webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"genCode('%@')", _qrCode]];
28-
}
25+
- (void)setQRCode:(NSString*) qrCode {
26+
CGImageRef cgImgRef = [self createQRImageForString:qrCode size:CGSizeMake(250, 250)];
27+
28+
NSImage *image = [[NSImage alloc]initWithCGImage:cgImgRef size:CGSizeMake(250, 250)];
29+
self.imageView.image = image;
2930
}
3031

31-
-(void)dealloc {
32-
self.webView.frameLoadDelegate = nil;
32+
- (CGImageRef)createQRImageForString:(NSString *)string size:(CGSize)size {
33+
// Setup the QR filter with our string
34+
CIFilter *filter = [CIFilter filterWithName:@"CIQRCodeGenerator"];
35+
[filter setDefaults];
36+
37+
NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
38+
[filter setValue:data forKey:@"inputMessage"];
39+
CIImage *image = [filter valueForKey:@"outputImage"];
40+
41+
// Calculate the size of the generated image and the scale for the desired image size
42+
CGRect extent = CGRectIntegral(image.extent);
43+
CGFloat scale = MIN(size.width / CGRectGetWidth(extent), size.height / CGRectGetHeight(extent));
44+
45+
// Since CoreImage nicely interpolates, we need to create a bitmap image that we'll draw into
46+
// a bitmap context at the desired size;
47+
size_t width = CGRectGetWidth(extent) * scale;
48+
size_t height = CGRectGetHeight(extent) * scale;
49+
CGColorSpaceRef cs = CGColorSpaceCreateDeviceGray();
50+
CGContextRef bitmapRef = CGBitmapContextCreate(nil, width, height, 8, 0, cs, (CGBitmapInfo)kCGImageAlphaNone);
51+
52+
#if TARGET_OS_IPHONE
53+
CIContext *context = [CIContext contextWithOptions:nil];
54+
#else
55+
CIContext *context = [CIContext contextWithCGContext:bitmapRef options:nil];
56+
#endif
57+
58+
CGImageRef bitmapImage = [context createCGImage:image fromRect:extent];
59+
60+
CGContextSetInterpolationQuality(bitmapRef, kCGInterpolationNone);
61+
CGContextScaleCTM(bitmapRef, scale, scale);
62+
CGContextDrawImage(bitmapRef, extent, bitmapImage);
63+
64+
// Create an image with the contents of our bitmap
65+
CGImageRef scaledImage = CGBitmapContextCreateImage(bitmapRef);
66+
67+
// Cleanup
68+
CGContextRelease(bitmapRef);
69+
CGImageRelease(bitmapImage);
70+
71+
return scaledImage;
3372
}
3473

3574
@end

0 commit comments

Comments
 (0)