Skip to content

Commit 9c10e72

Browse files
committed
Merge pull request shadowsocks#103 from minoscc/master
custom rules save to user-rule.txt
2 parents b8e6f5a + 76882a3 commit 9c10e72

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

ShadowsocksX/SWBAppDelegate.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ @implementation SWBAppDelegate {
3535
FSEventStreamRef fsEventStream;
3636
NSString *configPath;
3737
NSString *PACPath;
38+
NSString *userRulePath;
3839
AFHTTPRequestOperationManager *manager;
3940
}
4041

@@ -111,6 +112,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
111112

112113
configPath = [NSString stringWithFormat:@"%@/%@", NSHomeDirectory(), @".ShadowsocksX"];
113114
PACPath = [NSString stringWithFormat:@"%@/%@", configPath, @"gfwlist.js"];
115+
userRulePath = [NSString stringWithFormat:@"%@/%@", configPath, @"user-rule.txt"];
114116
[self monitorPAC:configPath];
115117
appDelegate = self;
116118
}
@@ -452,6 +454,13 @@ - (void)updatePACFromGFWList {
452454
// Objective-C is bullshit
453455
NSString *str2 = [[NSString alloc] initWithData:data2 encoding:NSUTF8StringEncoding];
454456
NSArray *lines = [str2 componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
457+
458+
NSString *str3 = [[NSString alloc] initWithContentsOfFile:userRulePath encoding:NSUTF8StringEncoding error:nil];
459+
if (str3) {
460+
NSArray *rules = [str3 componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
461+
lines = [lines arrayByAddingObjectsFromArray:rules];
462+
}
463+
455464
NSMutableArray *filtered = [[NSMutableArray alloc] init];
456465
for (NSString *line in lines) {
457466
if ([line length] > 0) {

0 commit comments

Comments
 (0)