summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-05-11 18:56:22 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-05-11 18:56:22 +0000
commit16d94ef4c69af91f99bc6457484c74d72e5de895 (patch)
treee4deb27ae56e710b52aad1d8d443e4ac6f239a38 /src
parentb830319a5cd670ee5a6a2ea4e29d7ca75e024d52 (diff)
Allow removal of client ports from the config file via rehash
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6984 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/socket.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/socket.cpp b/src/socket.cpp
index a828d1ece..2e7d04fdf 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -472,6 +472,12 @@ int InspIRCd::BindPorts(bool bail, int &ports_found, FailedPortList &failed_port
{
char configToken[MAXBUF], Addr[MAXBUF], Type[MAXBUF];
int bound = 0;
+ bool started_with_nothing = (Config->ports.size() == 0);
+ std::vector<std::pair<std::string, int> > old_ports;
+
+ /* XXX: Make a copy of the old ip/port pairs here */
+ for (std::vector<ListenSocket*>::iterator o = Config->ports.begin(); o != Config->ports.end(); ++o)
+ old_ports.push_back(make_pair((*o)->GetIP(), (*o)->GetPort()));
for (int count = 0; count < Config->ConfValueEnum(Config->config_data, "bind"); count++)
{
@@ -490,8 +496,21 @@ int InspIRCd::BindPorts(bool bail, int &ports_found, FailedPortList &failed_port
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);
@@ -509,6 +528,25 @@ int InspIRCd::BindPorts(bool bail, int &ports_found, FailedPortList &failed_port
}
}
}
+
+ /* XXX: Here, anything left in our copy list, close as removed */
+ if (!started_with_nothing)
+ {
+ for (size_t k = 0; k < old_ports.size(); ++k)
+ {
+ for (std::vector<ListenSocket*>::iterator n = Config->ports.begin(); n != Config->ports.end(); ++n)
+ {
+ if (((*n)->GetIP() == old_ports[k].first) && ((*n)->GetPort() == old_ports[k].second))
+ {
+ this->Log(DEFAULT,"Port binding %s:%d was removed from the config file, closing.", old_ports[k].first.c_str(), old_ports[k].second);
+ delete *n;
+ Config->ports.erase(n);
+ break;
+ }
+ }
+ }
+ }
+
return bound;
}