std::string IP = Conf.ReadValue("bind","address",j);
if (Type == "servers")
{
- if ((IP != "*") && (IP != "127.0.0.1") && (IP != ""))
+ if ((IP != "*") && (IP != "127.0.0.1") && (IP != "") && (IP != "::1"))
{
insp_sockaddr s;
if (insp_aton(IP.c_str(),&n) > 0)
{
#ifdef IPV6
- s.sin6_addr = n;
+ memcpy(&s.sin6_addr, &n, sizeof(n));
s.sin6_family = AF_FAMILY;
#else
s.sin_addr = n;
insp_aton(this->IP,&addy);
#ifdef IPV6
addr.sin6_family = AF_FAMILY;
- memcpy(&addr.sin6_addr, &addy, sizeof(insp_inaddr));
+ memcpy(&addr.sin6_addr, &addy, sizeof(addy));
addr.sin6_port = htons(this->port);
#else
addr.sin_family = AF_FAMILY;
addr.sin_port = htons(this->port);
#endif
- int flags;
- flags = fcntl(this->fd, F_GETFL, 0);
+ int flags = fcntl(this->fd, F_GETFL, 0);
fcntl(this->fd, F_SETFL, flags | O_NONBLOCK);
if (connect(this->fd, (sockaddr*)&this->addr,sizeof(this->addr)) == -1)
void InspSocket::Close()
{
+ /* Save this, so we dont lose it,
+ * otherise on failure, error messages
+ * might be inaccurate.
+ */
+ int save = errno;
if (this->fd > -1)
{
if (this->IsIOHooked && Instance->Config->GetIOHook(this))
shutdown(this->fd,2);
close(this->fd);
}
+ errno = save;
}
std::string InspSocket::GetIP()