X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fsocket.cpp;h=649f3ee5f03e3bfaf806fb2a4c1d1d557faef8e1;hb=75f147a25e8ecd30ada36c4b0a60c1b8c0e0717f;hp=01c07e2d093651b50ef3cdfe4befd1525ca9a711;hpb=74f401f1997b89783217cd636f396e35f5c2a9d0;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/socket.cpp b/src/socket.cpp index 01c07e2d0..649f3ee5f 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -2,7 +2,7 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd: (C) 2002-2008 InspIRCd Development Team + * InspIRCd: (C) 2002-2009 InspIRCd Development Team * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see @@ -20,7 +20,7 @@ /** This will bind a socket to a port. It works for UDP/TCP. * It can only bind to IP addresses, if you wish to bind to hostnames * you should first resolve them using class 'Resolver'. - */ + */ bool InspIRCd::BindSocket(int sockfd, int port, const char* addr, bool dolisten) { /* We allocate 2 of these, because sockaddr_in6 is larger than sockaddr (ugh, hax) */ @@ -143,14 +143,20 @@ bool InspIRCd::BindSocket(int sockfd, int port, const char* addr, bool dolisten) } // Open a TCP Socket -int irc::sockets::OpenTCPSocket(char* addr, int socktype) +int irc::sockets::OpenTCPSocket(const char* addr, int socktype) { int sockfd; int on = 1; addr = addr; struct linger linger = { 0, 0 }; #ifdef IPV6 - if (strchr(addr,':') || (!*addr)) + if (!*addr) + { + sockfd = socket (PF_INET6, socktype, 0); + if (sockfd < 0) + sockfd = socket (PF_INET, socktype, 0); + } + else if (strchr(addr,':')) sockfd = socket (PF_INET6, socktype, 0); else sockfd = socket (PF_INET, socktype, 0); @@ -189,10 +195,10 @@ int InspIRCd::BindPorts(bool, int &ports_found, FailedPortList &failed_ports) Config->ConfValue(Config->config_data, "bind", "port", count, configToken, MAXBUF); Config->ConfValue(Config->config_data, "bind", "address", count, Addr, MAXBUF); Config->ConfValue(Config->config_data, "bind", "type", count, Type, MAXBUF); - + if (strncmp(Addr, "::ffff:", 7) == 0) this->Logs->Log("SOCKET",DEFAULT, "Using 4in6 (::ffff:) isn't recommended. You should bind IPv4 addresses directly instead."); - + if ((!*Type) || (!strcmp(Type,"clients"))) { irc::portparser portrange(configToken, false);