summaryrefslogtreecommitdiff
path: root/src/socket.cpp
diff options
context:
space:
mode:
authorGravatar brain2006-06-28 10:54:24 +0000
committerGravatar brain2006-06-28 10:54:24 +0000
commit03522584b490f299ce53a6958ebb7484dd3a77c6 (patch)
treee5f02bd47015d4f92365459ee963cc022ce14633 /src/socket.cpp
parentRemove references to hostnames in <link> tag, use ip's instead (diff)
Allow binding by hostname again in <link> and <bind>
git-svn-id: http://svn.inspircd.org/repository/branches/1_0_stable@4075 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/socket.cpp')
-rw-r--r--src/socket.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/socket.cpp b/src/socket.cpp
index 6616ebf0a..53a26eca8 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -36,6 +36,7 @@ using namespace std;
#include "inspstring.h"
#include "helperfuncs.h"
#include "socketengine.h"
+#include "message.h"
extern InspIRCd* ServerInstance;
@@ -179,10 +180,22 @@ bool InspSocket::BindAddr()
std::string IP = Conf.ReadValue("bind","address",j);
if (Type == "servers")
{
- if ((IP != "*") && (IP != "127.0.0.1"))
+ if ((IP != "*") && (IP != "127.0.0.1") && (IP != ""))
{
sockaddr_in s;
+ char resolved_addr[MAXBUF];
+ if (!inet_aton(IP.c_str(),&n))
+ {
+ /* If they gave a hostname, bind to the IP it resolves to */
+ log(DEBUG,"Resolving host %s",IP.c_str());
+ if (CleanAndResolve(resolved_addr, IP.c_str(), true))
+ {
+ log(DEBUG,"Resolved host %s to %s",IP.c_str(),resolved_addr);
+ IP = resolved_addr;
+ }
+ }
+
if (inet_aton(IP.c_str(),&n))
{
log(DEBUG,"Found an IP to bind to: %s",IP.c_str());