mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Use loopback interface.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@17213 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ab38554fd9
commit
bb3e95339a
3 changed files with 39 additions and 4 deletions
|
@ -1,3 +1,9 @@
|
|||
2003-07-15 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSDistributedNotificationCenter.m: Use loopback network
|
||||
interface for local center.
|
||||
* Tools/gdnc.m: ditto.
|
||||
|
||||
2003-07-11 David Ayers <d.ayers@inode.at>
|
||||
|
||||
* Source/GNUmakefile: Make GNUstep.h public.
|
||||
|
|
|
@ -566,7 +566,7 @@ static NSDistributedNotificationCenter *netCenter = nil;
|
|||
stringForKey: @"NSHost"];
|
||||
if (host == nil)
|
||||
{
|
||||
host = @"";
|
||||
host = @"localhost";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -593,7 +593,9 @@ static NSDistributedNotificationCenter *netCenter = nil;
|
|||
host = [h name];
|
||||
}
|
||||
}
|
||||
if ([host length] == 0)
|
||||
if ([host length] == 0
|
||||
|| [host isEqualToString: @"localhost"] == YES
|
||||
|| [host isEqualToString: @"127.0.0.1"] == YES)
|
||||
{
|
||||
description = @"local host";
|
||||
}
|
||||
|
|
31
Tools/gdnc.m
31
Tools/gdnc.m
|
@ -34,6 +34,8 @@
|
|||
#define NSIG 32
|
||||
#endif
|
||||
|
||||
@class GSTcpPort;
|
||||
|
||||
static void
|
||||
ihandler(int sig)
|
||||
{
|
||||
|
@ -300,14 +302,13 @@ ihandler(int sig)
|
|||
{
|
||||
NSString *hostname;
|
||||
NSString *service = GDNC_SERVICE;
|
||||
BOOL isLocal = NO;
|
||||
|
||||
connections = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
||||
NSNonOwnedPointerMapValueCallBacks, 0);
|
||||
allObservers = NSCreateHashTable(NSNonOwnedPointerHashCallBacks, 0);
|
||||
observersForNames = [NSMutableDictionary new];
|
||||
observersForObjects = [NSMutableDictionary new];
|
||||
conn = [NSConnection defaultConnection];
|
||||
[conn setRootObject: self];
|
||||
|
||||
if ([[NSUserDefaults standardUserDefaults] boolForKey: @"GSNetwork"] == YES)
|
||||
{
|
||||
|
@ -315,6 +316,32 @@ ihandler(int sig)
|
|||
}
|
||||
hostname = [[NSUserDefaults standardUserDefaults] stringForKey: @"NSHost"];
|
||||
if ([hostname length] == 0
|
||||
|| [hostname isEqualToString: @"localhost"] == YES
|
||||
|| [hostname isEqualToString: @"127.0.0.1"] == YES)
|
||||
{
|
||||
isLocal = YES;
|
||||
}
|
||||
|
||||
/*
|
||||
* If this is the local server for the current host,
|
||||
* use the loopback network interface. Otherwise
|
||||
* create a public connection.
|
||||
*/
|
||||
if (isLocal == YES && service != GDNC_NETWORK)
|
||||
{
|
||||
NSPort *port = [GSTcpPort portWithNumber: 0
|
||||
onHost: [NSHost localHost]
|
||||
forceAddress: @"127.0.0.1"
|
||||
listener: YES];
|
||||
conn = [[NSConnection alloc] initWithReceivePort: port sendPort: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
conn = [NSConnection defaultConnection];
|
||||
}
|
||||
[conn setRootObject: self];
|
||||
|
||||
if (isLocal == YES
|
||||
|| [[NSHost hostWithName: hostname] isEqual: [NSHost currentHost]] == YES)
|
||||
{
|
||||
if ([conn registerName: service] == NO)
|
||||
|
|
Loading…
Reference in a new issue