diff --git a/ChangeLog b/ChangeLog
index 6a862f217..6335a8f4a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,15 @@
contigure.ac:
Add --enable-xslt option to require stylesheet support (in case we want
to start uisng it to generate documentation)
+ * Headers/Foundation/NSURLHandle.h:
+ * Source/GSFileHandle.m:
+ * Source/GSHTTPURLHandle.m:
+ * Source/NSFileHandle.m:
+ * Source/NSURLHandle.m:
+ Support binding to specific local ip address for outgoing connections
+ in gnustep extensions.
+ * Source/GSMime.m: ([-setContent:]), ([-addContent:]) Check that
+ content of a multipart document consists of GSMimeDocument objects.
2004-03-29 Adrian Robert
@@ -795,6 +821,21 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
RELEASE(self);
return nil;
}
+ if (lhost != nil)
+ {
+ if (bind(net, (struct sockaddr *)&lsin, sizeof(lsin)) == SOCKET_ERROR)
+ {
+ NSLog(@"unable to bind to port %s:%d - %s", inet_ntoa(lsin.sin_addr),
+ GSSwapBigI16ToHost(sin.sin_port), GSLastErrorStr(errno));
+#if defined(__MINGW__)
+ (void) closesocket(net);
+#else
+ (void) close(net);
+#endif
+ RELEASE(self);
+ return nil;
+ }
+ }
#if defined(__MINGW__)
self = [self initWithNativeHandle: (void*)net closeOnDealloc: YES];
diff --git a/Source/GSHTTPURLHandle.m b/Source/GSHTTPURLHandle.m
index d8a88cada..33564d19d 100644
--- a/Source/GSHTTPURLHandle.m
+++ b/Source/GSHTTPURLHandle.m
@@ -161,6 +161,12 @@ char emp[64] = {
* secure connection when a proxy is specified, GSHTTPURLHandle will
* attempt to open an SSL Tunnel through the proxy.
*
+ * Requests to the remote server may be forced to be bound to a + * particular local IP address by using the key + * "GSHTTPPropertyLocalHostKey" which must contain the + * IP address of a network interface on the local host. + *
*/ @implementation GSHTTPURLHandle @@ -450,6 +456,7 @@ static void debugWrite(NSData *data) NSNotificationCenter *nc; NSString *host = nil; NSString *port = nil; + NSString *s; /* * Don't start a load if one is in progress. @@ -471,6 +478,20 @@ static void debugWrite(NSData *data) [sock closeFile]; DESTROY(sock); } + + /* + * If we have a local address specified, tell the file handle to bind to it. + */ + s = [request objectForKey: GSHTTPPropertyLocalHostKey]; + if ([s length] > 0) + { + s = [NSString stringWithFormat: @"bind-%@", s]; + } + else + { + s = @"tcp"; // Bind to any. + } + if ([[request objectForKey: GSHTTPPropertyProxyHostKey] length] == 0) { NSNumber *p; @@ -493,17 +514,15 @@ static void debugWrite(NSData *data) @"https not supported ... needs SSL bundle"]; return; } - sock = [sslClass - fileHandleAsClientInBackgroundAtAddress: host - service: port - protocol: @"tcp"]; + sock = [sslClass fileHandleAsClientInBackgroundAtAddress: host + service: port + protocol: s]; } else { - sock = [NSFileHandle - fileHandleAsClientInBackgroundAtAddress: host - service: port - protocol: @"tcp"]; + sock = [NSFileHandle fileHandleAsClientInBackgroundAtAddress: host + service: port + protocol: s]; } } else @@ -522,19 +541,17 @@ static void debugWrite(NSData *data) } host = [request objectForKey: GSHTTPPropertyProxyHostKey]; port = [request objectForKey: GSHTTPPropertyProxyPortKey]; - sock = [sslClass - fileHandleAsClientInBackgroundAtAddress: host - service: port - protocol: @"tcp"]; + sock = [sslClass fileHandleAsClientInBackgroundAtAddress: host + service: port + protocol: s]; } else { host = [request objectForKey: GSHTTPPropertyProxyHostKey]; port = [request objectForKey: GSHTTPPropertyProxyPortKey]; - sock = [NSFileHandle - fileHandleAsClientInBackgroundAtAddress: host - service: port - protocol: @"tcp"]; + sock = [NSFileHandle fileHandleAsClientInBackgroundAtAddress: host + service: port + protocol: s]; } } if (sock == nil) diff --git a/Source/NSFileHandle.m b/Source/NSFileHandle.m index 02ff4ef92..fe5218860 100644 --- a/Source/NSFileHandle.m +++ b/Source/NSFileHandle.m @@ -428,7 +428,10 @@ NSString * const NSFileHandleOperationException * is not made via a socks server.