- 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);
- int portno = -1;
- while (0 != (portno = portrange.GetToken()))
- {
- if (*Addr == '*')
- *Addr = 0;
-
- bool skip = false;
- for (std::vector<ListenSocket*>::iterator n = Config->ports.begin(); n != Config->ports.end(); ++n)
- {
- if (((*n)->GetIP() == Addr) && ((*n)->GetPort() == portno))
- {
- skip = true;
- /* XXX: Here, erase from our copy of the list */
- for (std::vector<std::pair<std::string, int> >::iterator k = old_ports.begin(); k != old_ports.end(); ++k)
- {
- if ((k->first == Addr) && (k->second == portno))
- {
- old_ports.erase(k);
- break;
- }
- }
- }
- }
- if (!skip)
- {
- ListenSocket* ll = new ListenSocket(this, portno, Addr);
- if (ll->GetFd() > -1)
- {
- bound++;
- Config->ports.push_back(ll);
- }
- else
- {
- failed_ports.push_back(std::make_pair((*Addr ? Addr : "*") + std::string(":") + ConvToStr(portno), strerror(errno)));
- }
- ports_found++;
- }
- }
- }
+ case AF_UNIX:
+ // XXX: UNIX sockets don't support CIDR. This fix is non-ideal but I can't
+ // really think of another way to handle it.
+ cidr.length = 0;
+ return;
+
+ case AF_INET:
+ cidr.length = range > 32 ? 32 : range;
+ target_byte = sizeof(sa.in4.sin_addr);
+ base = (unsigned char*)&sa.in4.sin_addr;
+ break;
+
+ case AF_INET6:
+ cidr.length = range > 128 ? 128 : range;
+ target_byte = sizeof(sa.in6.sin6_addr);
+ base = (unsigned char*)&sa.in6.sin6_addr;
+ break;
+
+ default:
+ // If we have reached this point then we have encountered a bug.
+ ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "BUG: sa2cidr(): socket type %d is unknown!", cidr.type);
+ cidr.length = 0;
+ return;