Merge branch 'master' of metalzone:public-git/preload-hacks
authorMark Wooding <mdw@distorted.org.uk>
Sat, 26 Dec 2009 12:16:09 +0000 (12:16 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 26 Dec 2009 12:16:09 +0000 (12:16 +0000)
* 'master' of metalzone:public-git/preload-hacks:
  Version 1.0.4.
  noip (decode_inet_addr): Be more careful when converting addresses.
  noip: Don't try to support families other than AF_UNIX and AF_INET.

README
noip.c

diff --git a/README b/README
index 980f5a4..b067845 100644 (file)
--- a/README
+++ b/README
@@ -261,6 +261,25 @@ noip
        stuff that Emacs does magically find the SSH tunnel and work
        without me having to care.
 
+  Testing
+
+       noip provides a handy way for testing network servers and so on
+       safely.  For a start, you can run your test server apparently on
+       the same port as the real one.  Because noip consults the
+       environment variable NOIP_SOCKETDIR to find out where to put its
+       sockets, you can run two at a time and they don't interfere.
+       And noip doesn't care what port numbers your program tries to
+       bind, so you don't need to jump through stupid hoops in order to
+       test programs which use `privileged' ports.
+
+  Other applications
+
+       There are certainly loads of handy things you can do with noip.
+       If you think of one, let me know!
+
+                                                               Mark Wooding
+                                                       mdw@distorted.org.uk
+
 \f
 Local variables:
 mode: text
diff --git a/noip.c b/noip.c
index 04abe93..237bfd0 100644 (file)
--- a/noip.c
+++ b/noip.c
@@ -882,17 +882,22 @@ int connect(int sk, const struct sockaddr *sa, socklen_t len)
   int fixup_p = 0;
   int rc;
 
-  if (sa->sa_family == AF_INET) {
-    PRESERVING_ERRNO({
-      do_implicit_bind(sk, &sa, &len, &sun);
-      fixup_p = 1;
-    });
-  }
-  rc = real_connect(sk, sa, len);
-  if (rc < 0) {
-    switch (errno) {
-      case ENOENT:     errno = ECONNREFUSED;   break;
-    }
+  switch (sa->sa_family) {
+    case AF_INET:
+      PRESERVING_ERRNO({
+       do_implicit_bind(sk, &sa, &len, &sun);
+       fixup_p = 1;
+      });
+      rc = real_connect(sk, sa, len);
+      if (rc < 0) {
+       switch (errno) {
+         case ENOENT:  errno = ECONNREFUSED;   break;
+       }
+      }
+      break;
+    default:
+      rc = real_connect(sk, sa, len);
+      break;
   }
   return rc;
 }