Call webServer startWithOptions instead of startWithPort

建议使用 webServer.startWithOptions(["BindToLocalhost":true,"Port":xxxx]) 来避免提示允许监听端口
This commit is contained in:
Charlie Qiu
2016-10-02 01:24:38 +08:00
parent 25f8319e85
commit b389dc226c

View File

@ -176,7 +176,7 @@ GCDWebServer *webServer =nil;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString * address = [defaults stringForKey:@"PacServer.ListenAddress"]; NSString * address = [defaults stringForKey:@"PacServer.ListenAddress"];
int port = (short)[defaults integerForKey:@"PacServer.ListenPort"]; int port = (short)[defaults integerForKey:@"PacServer.ListenPort"];
[webServer startWithPort:port bonjourName:@"webserver"]; [webServer startWithOptions:@{@"BindToLocalhost":@YES, @"Port":@(port)} error:nil];
return [NSString stringWithFormat:@"%@%@:%d%@",@"http://",address,port,routerPath]; return [NSString stringWithFormat:@"%@%@:%d%@",@"http://",address,port,routerPath];
} }