aboutsummaryrefslogtreecommitdiff
path: root/src/socket.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2023-02-17 21:32:23 +0000
committerGravatar Sadie Powell2023-02-17 21:35:47 +0000
commitb35ec3290c480c04552943ac454e39fdc7dc248f (patch)
tree2bdb645bcb277a5f644816f4aaa76063aff66915 /src/socket.cpp
parentRefactor the chanhistory mode handler and allow limiting the duration. (diff)
Bind IP listeners with SCTP and TCP by default.
Diffstat (limited to 'src/socket.cpp')
-rw-r--r--src/socket.cpp52
1 files changed, 36 insertions, 16 deletions
diff --git a/src/socket.cpp b/src/socket.cpp
index 6932334d8..484dcf81d 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -81,18 +81,6 @@ size_t InspIRCd::BindPorts(FailedPortList& failed_ports)
if (strncasecmp(address.c_str(), "::ffff:", 7) == 0)
this->Logs.Warning("SOCKET", "Using 4in6 (::ffff:) isn't recommended. You should bind IPv4 addresses directly instead.");
- // Check whether this is a SCTP listener.
- int protocol = 0;
- if (tag->getBool("sctp"))
- {
-#ifdef IPPROTO_SCTP
- protocol = IPPROTO_SCTP;
-#else
- failed_ports.emplace_back("Platform does not support SCTP", tag);
- continue;
-#endif
- }
-
// Try to parse the bind address.
irc::sockets::sockaddrs bindspec(false);
if (!bindspec.from_ip(address))
@@ -132,10 +120,42 @@ size_t InspIRCd::BindPorts(FailedPortList& failed_ports)
continue; // Should never happen.
}
- if (!BindPort(tag, bindspec, old_ports, protocol))
- failed_ports.emplace_back(strerror(errno), bindspec, tag);
- else
- bound++;
+ std::vector<int> protocols;
+ irc::spacesepstream protostream(tag->getString("protocols", "all", 1));
+ for (std::string protocol; protostream.GetToken(protocol); )
+ {
+ if (stdalgo::string::equalsci(protocol, "all"))
+ {
+ protocols.push_back(0); // IPPROTO_TCP
+#ifdef IPPROTO_SCTP
+ protocols.push_back(IPPROTO_SCTP);
+#endif
+ }
+ else if (stdalgo::string::equalsci(protocol, "sctp"))
+ {
+#ifdef IPPROTO_SCTP
+ protocols.push_back(IPPROTO_SCTP);
+#else
+ failed_ports.emplace_back("Platform does not support SCTP", tag);
+#endif
+ }
+ else if (stdalgo::string::equalsci(protocol, "tcp"))
+ {
+ protocols.push_back(0); // IPPROTO_TCP
+ }
+ else
+ {
+ failed_ports.emplace_back("Protocol is not valid: " + protocol, tag);
+ }
+ }
+
+ for (const auto protocol : protocols)
+ {
+ if (!BindPort(tag, bindspec, old_ports, protocol))
+ failed_ports.emplace_back(strerror(errno), bindspec, tag);
+ else
+ bound++;
+ }
}
continue;
}