add adv settings for pac server

add adv settings for pac server address & port
handle accident crash on stop pac server
This commit is contained in:
qinyuhang
2016-08-25 09:19:47 +08:00
parent 66b0b622f0
commit cd1b1cd87f
5 changed files with 70 additions and 20 deletions

View File

@ -173,14 +173,18 @@ GCDWebServer *webServer =nil;
return [GCDWebServerDataResponse responseWithData: originalPACData contentType:@"application/x-ns-proxy-autoconfig"];
}
];
int port = 8090;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString * address = [defaults stringForKey:@"PacServer.ListenAddress"];
int port = (short)[defaults integerForKey:@"PacServer.ListenPort"];
[webServer startWithPort:port bonjourName:@"webserver"];
return [NSString stringWithFormat:@"%@%d%@",@"http://127.0.0.1:",port,routerPath];
return [NSString stringWithFormat:@"%@%@:%d%@",@"http://",address,port,routerPath];
}
+ (void)stopPACServer {
//webserver
[webServer stop];
if ([webServer isRunning]) {
[webServer stop];
}
}
@end