mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +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
e1512bb666
commit
10f0204dd5
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>
|
2003-07-11 David Ayers <d.ayers@inode.at>
|
||||||
|
|
||||||
* Source/GNUmakefile: Make GNUstep.h public.
|
* Source/GNUmakefile: Make GNUstep.h public.
|
||||||
|
|
|
@ -566,7 +566,7 @@ static NSDistributedNotificationCenter *netCenter = nil;
|
||||||
stringForKey: @"NSHost"];
|
stringForKey: @"NSHost"];
|
||||||
if (host == nil)
|
if (host == nil)
|
||||||
{
|
{
|
||||||
host = @"";
|
host = @"localhost";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -593,7 +593,9 @@ static NSDistributedNotificationCenter *netCenter = nil;
|
||||||
host = [h name];
|
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";
|
description = @"local host";
|
||||||
}
|
}
|
||||||
|
|
31
Tools/gdnc.m
31
Tools/gdnc.m
|
@ -34,6 +34,8 @@
|
||||||
#define NSIG 32
|
#define NSIG 32
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@class GSTcpPort;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ihandler(int sig)
|
ihandler(int sig)
|
||||||
{
|
{
|
||||||
|
@ -300,14 +302,13 @@ ihandler(int sig)
|
||||||
{
|
{
|
||||||
NSString *hostname;
|
NSString *hostname;
|
||||||
NSString *service = GDNC_SERVICE;
|
NSString *service = GDNC_SERVICE;
|
||||||
|
BOOL isLocal = NO;
|
||||||
|
|
||||||
connections = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
connections = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
||||||
NSNonOwnedPointerMapValueCallBacks, 0);
|
NSNonOwnedPointerMapValueCallBacks, 0);
|
||||||
allObservers = NSCreateHashTable(NSNonOwnedPointerHashCallBacks, 0);
|
allObservers = NSCreateHashTable(NSNonOwnedPointerHashCallBacks, 0);
|
||||||
observersForNames = [NSMutableDictionary new];
|
observersForNames = [NSMutableDictionary new];
|
||||||
observersForObjects = [NSMutableDictionary new];
|
observersForObjects = [NSMutableDictionary new];
|
||||||
conn = [NSConnection defaultConnection];
|
|
||||||
[conn setRootObject: self];
|
|
||||||
|
|
||||||
if ([[NSUserDefaults standardUserDefaults] boolForKey: @"GSNetwork"] == YES)
|
if ([[NSUserDefaults standardUserDefaults] boolForKey: @"GSNetwork"] == YES)
|
||||||
{
|
{
|
||||||
|
@ -315,6 +316,32 @@ ihandler(int sig)
|
||||||
}
|
}
|
||||||
hostname = [[NSUserDefaults standardUserDefaults] stringForKey: @"NSHost"];
|
hostname = [[NSUserDefaults standardUserDefaults] stringForKey: @"NSHost"];
|
||||||
if ([hostname length] == 0
|
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)
|
|| [[NSHost hostWithName: hostname] isEqual: [NSHost currentHost]] == YES)
|
||||||
{
|
{
|
||||||
if ([conn registerName: service] == NO)
|
if ([conn registerName: service] == NO)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue