|
@@ -171,6 +171,7 @@ static void _ExecuteMainThreadRunLoopSources() {
|
|
dispatch_source_t _source6;
|
|
dispatch_source_t _source6;
|
|
CFNetServiceRef _registrationService;
|
|
CFNetServiceRef _registrationService;
|
|
CFNetServiceRef _resolutionService;
|
|
CFNetServiceRef _resolutionService;
|
|
|
|
+ BOOL _bindToLocalhost;
|
|
#if TARGET_OS_IPHONE
|
|
#if TARGET_OS_IPHONE
|
|
BOOL _suspendInBackground;
|
|
BOOL _suspendInBackground;
|
|
UIBackgroundTaskIdentifier _backgroundTask;
|
|
UIBackgroundTaskIdentifier _backgroundTask;
|
|
@@ -554,6 +555,7 @@ static inline NSString* _EncodeBase64(NSString* string) {
|
|
_source4 = [self _createDispatchSourceWithListeningSocket:listeningSocket4 isIPv6:NO];
|
|
_source4 = [self _createDispatchSourceWithListeningSocket:listeningSocket4 isIPv6:NO];
|
|
_source6 = [self _createDispatchSourceWithListeningSocket:listeningSocket6 isIPv6:YES];
|
|
_source6 = [self _createDispatchSourceWithListeningSocket:listeningSocket6 isIPv6:YES];
|
|
_port = port;
|
|
_port = port;
|
|
|
|
+ _bindToLocalhost = bindToLocalhost;
|
|
|
|
|
|
NSString* bonjourName = _GetOption(_options, GCDWebServerOption_BonjourName, nil);
|
|
NSString* bonjourName = _GetOption(_options, GCDWebServerOption_BonjourName, nil);
|
|
NSString* bonjourType = _GetOption(_options, GCDWebServerOption_BonjourType, @"_http._tcp");
|
|
NSString* bonjourType = _GetOption(_options, GCDWebServerOption_BonjourType, @"_http._tcp");
|
|
@@ -619,6 +621,7 @@ static inline NSString* _EncodeBase64(NSString* string) {
|
|
#endif
|
|
#endif
|
|
_source4 = NULL;
|
|
_source4 = NULL;
|
|
_port = 0;
|
|
_port = 0;
|
|
|
|
+ _bindToLocalhost = NO;
|
|
|
|
|
|
_serverName = nil;
|
|
_serverName = nil;
|
|
_authenticationRealm = nil;
|
|
_authenticationRealm = nil;
|
|
@@ -715,7 +718,7 @@ static inline NSString* _EncodeBase64(NSString* string) {
|
|
|
|
|
|
- (NSURL*)serverURL {
|
|
- (NSURL*)serverURL {
|
|
if (_source4) {
|
|
if (_source4) {
|
|
- NSString* ipAddress = GCDWebServerGetPrimaryIPAddress(NO); // We can't really use IPv6 anyway as it doesn't work great with HTTP URLs in practice
|
|
|
|
|
|
+ NSString* ipAddress = _bindToLocalhost ? @"localhost" : GCDWebServerGetPrimaryIPAddress(NO); // We can't really use IPv6 anyway as it doesn't work great with HTTP URLs in practice
|
|
if (ipAddress) {
|
|
if (ipAddress) {
|
|
if (_port != 80) {
|
|
if (_port != 80) {
|
|
return [NSURL URLWithString:[NSString stringWithFormat:@"http://%@:%i/", ipAddress, (int)_port]];
|
|
return [NSURL URLWithString:[NSString stringWithFormat:@"http://%@:%i/", ipAddress, (int)_port]];
|