diff options
author | Matt Johnston <matt@ucc.asn.au> | 2004-08-11 17:26:47 +0000 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2004-08-11 17:26:47 +0000 |
commit | 453261a0420a1e4ee5d0feb3df6806c39ae3e0ff (patch) | |
tree | dffe7a4d63c88753c9763cbbe584d3d95d1a95f2 /dbutil.c | |
parent | a712baa8e566bfd8403a3e2bfdf350a0dc50ea9f (diff) |
- A nice cleaner structure for tcp (acceptor) forwarding.
- still a checkpoint-ish commit
- sorted out listening on localhost only
--HG--
extra : convert_revision : c030ac0a3950dba81f2324e2ba9d4b77fc8f8149
Diffstat (limited to 'dbutil.c')
-rw-r--r-- | dbutil.c | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -114,10 +114,8 @@ void dropbear_trace(const char* format, ...) { #endif /* DEBUG_TRACE */ /* Listen on address:port. Unless address is NULL, in which case listen on - * everything (ie 0.0.0.0, or ::1 - note that this is IPv? agnostic. Linux is - * broken with respect to listening to v6 or v4, so the addresses you get when - * people connect will be wrong. It doesn't break things, just looks quite - * ugly. Returns the number of sockets bound on success, or -1 on failure. On + * everything. If called with address == "", we'll listen on localhost/loopback. + * Returns the number of sockets bound on success, or -1 on failure. On * failure, if errstring wasn't NULL, it'll be a newly malloced error * string.*/ int dropbear_listen(const char* address, const char* port, @@ -135,7 +133,14 @@ int dropbear_listen(const char* address, const char* port, memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; /* TODO: let them flag v4 only etc */ hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_PASSIVE; + + if (address && address[0] == '\0') { + TRACE(("dropbear_listen: local loopback")); + address = NULL; + } else { + TRACE(("dropbear_listen: not local loopback")); + hints.ai_flags = AI_PASSIVE; + } err = getaddrinfo(address, port, &hints, &res0); if (err) { |