summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/example.conf25
-rw-r--r--include/anope.h7
-rw-r--r--include/config.h4
-rw-r--r--include/dns.h4
-rw-r--r--include/extern.h16
-rw-r--r--include/modules.h12
-rw-r--r--include/services.h13
-rw-r--r--include/sockets.h56
-rw-r--r--modules/core/db_mysql.cpp2
-rw-r--r--modules/core/os_restart.cpp2
-rw-r--r--modules/core/os_shutdown.cpp2
-rw-r--r--modules/extra/m_ssl.cpp152
-rw-r--r--modules/extra/m_xmlrpc.cpp37
-rw-r--r--modules/protocol/bahamut.cpp2
-rw-r--r--modules/protocol/inspircd-ts6.h2
-rw-r--r--modules/protocol/inspircd11.cpp2
-rw-r--r--modules/protocol/plexus.cpp2
-rw-r--r--modules/protocol/ratbox.cpp2
-rw-r--r--modules/protocol/unreal.cpp2
-rw-r--r--src/config.cpp3
-rw-r--r--src/dns.cpp23
-rw-r--r--src/init.cpp1
-rw-r--r--src/main.cpp444
-rw-r--r--src/messages.cpp2
-rw-r--r--src/misc.cpp9
-rw-r--r--src/modulemanager.cpp8
-rw-r--r--src/socketengines/socketengine_epoll.cpp2
-rw-r--r--src/socketengines/socketengine_poll.cpp2
-rw-r--r--src/socketengines/socketengine_select.cpp2
-rw-r--r--src/sockets.cpp132
30 files changed, 525 insertions, 447 deletions
diff --git a/data/example.conf b/data/example.conf
index f98b8b9f5..6aed17fda 100644
--- a/data/example.conf
+++ b/data/example.conf
@@ -457,14 +457,6 @@ options
botmodes = "ao"
/*
- * How many times services should attempt to reconnect to the uplink before giving up
- * Comment this out to never give up.
- *
- * This directive is optional.
- */
- maxretries = 10
-
- /*
* How long to wait between connection retries, in seconds.
*/
retrywait = 60
@@ -707,17 +699,19 @@ oper
#certfp = "ed3383b3f7d74e89433ddaa4a6e5b2d7"
}
+/*
oper
{
- #name = "nick2"
+ name = "nick2"
type = "Services Administrator"
}
oper
{
- #name = "nick3"
+ name = "nick3"
type = "Helper"
}
+*/
/*
* [OPTIONAL] Mail Config
@@ -1742,16 +1736,19 @@ defcon
* You may also include executable files, which will be executed and
* the output from it will be included into your configuration.
*/
+
+/*
include
{
- #type = "file"
- #name = "some_other.conf"
+ type = "file"
+ name = "some_other.conf"
}
include
{
- #type = "executable"
- #name = "/usr/bin/wget -q -O - http://some.miconfigured.network.com/services.conf"
+ type = "executable"
+ name = "/usr/bin/wget -q -O - http://some.miconfigured.network.com/services.conf"
}
+*/
/*
* [OPTIONAL] Non-Core Modules
diff --git a/include/anope.h b/include/anope.h
index 0e25bbb93..83f45d39b 100644
--- a/include/anope.h
+++ b/include/anope.h
@@ -368,7 +368,12 @@ namespace Anope
*/
extern CoreExport string printf(const char *fmt, ...);
- /** Return the last error, uses errno/GetLastError() to determin this
+ /** Return the last error code
+ * @return The error code
+ */
+ extern CoreExport int LastErrorCode();
+
+ /** Return the last error, uses errno/GetLastError() to determine this
* @return An error message
*/
extern CoreExport const Anope::string LastError();
diff --git a/include/config.h b/include/config.h
index b06aa60d8..07815466e 100644
--- a/include/config.h
+++ b/include/config.h
@@ -345,7 +345,7 @@ class CoreExport ServerConfig
/* Host to connect to **/
Anope::string LocalHost;
/* List of uplink servers to try and connect to */
- std::list<Uplink *> Uplinks;
+ std::vector<Uplink *> Uplinks;
/* Our server name */
Anope::string ServerName;
@@ -453,8 +453,6 @@ class CoreExport ServerConfig
Anope::string BotModes;
/* THe actual modes */
ChannelStatus BotModeList;
- /* How many times to try and reconnect to the uplink before giving up */
- unsigned MaxRetries;
/* How long to wait between connection attempts */
int RetryWait;
/* If services should hide unprivileged commands */
diff --git a/include/dns.h b/include/dns.h
index 6e79603d7..cb6d6b5c7 100644
--- a/include/dns.h
+++ b/include/dns.h
@@ -152,6 +152,10 @@ class DNSSocket : public ConnectionSocket
bool ProcessRead();
bool ProcessWrite();
+
+ void OnConnect();
+
+ void OnError(const Anope::string &error);
};
/** DNS manager, manages the connection and all requests
diff --git a/include/extern.h b/include/extern.h
index 0b319ceaf..7774c104f 100644
--- a/include/extern.h
+++ b/include/extern.h
@@ -85,7 +85,6 @@ E void introduce_user(const Anope::string &user);
E bool GetCommandLineArgument(const Anope::string &name, char shortname = 0);
E bool GetCommandLineArgument(const Anope::string &name, char shortname, Anope::string &param);
E void Init(int ac, char **av);
-E Uplink *uplink_server;
/**** ircd.c ****/
E void pmodule_ircd_proto(IRCDProto *);
@@ -114,27 +113,16 @@ E bool noexpire;
E bool protocoldebug;
E bool quitting;
-E bool shutting_down;
+E bool restarting;
E Anope::string quitmsg;
E bool save_data;
E time_t start_time;
E ConnectionSocket *UplinkSock;
+E int CurrentUplink;
E void save_databases();
E void sighandler(int signum);
-E void do_restart_services();
-
-/* The socket to our uplink */
-class CoreExport UplinkSocket : public ConnectionSocket
-{
- public:
- UplinkSocket(bool ipv6 = false);
-
- virtual ~UplinkSocket();
-
- bool Read(const Anope::string &buf);
-};
/**** messages.cpp ****/
diff --git a/include/modules.h b/include/modules.h
index d24348b48..ff0c576a0 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -481,12 +481,9 @@ class CoreExport Module : public Extensible
*/
virtual void OnChanExpire(ChannelInfo *ci) { }
- /** Called before Anope connects to its uplink
- * @param u The uplink we're going to connect to
- * @param Number What number the uplink is
- * @return Other than EVENT_CONTINUE to stop attempting to connect
+ /** Called before Anope connecs to its uplink
*/
- virtual EventReturn OnPreServerConnect(Uplink *u, int Number) { return EVENT_CONTINUE; }
+ virtual void OnPreServerConnect() { }
/** Called when Anope connects to its uplink
*/
@@ -1079,7 +1076,7 @@ enum Implementation
I_OnModuleLoad, I_OnModuleUnload,
/* Other */
- I_OnReload, I_OnPreServerConnect, I_OnNewServer, I_OnServerConnect, I_OnPreUplinkSync, I_OnServerDisconnect, I_OnPreCommandRun,
+ I_OnReload, I_OnNewServer, I_OnPreServerConnect, I_OnServerConnect, I_OnPreUplinkSync, I_OnServerDisconnect, I_OnPreCommandRun,
I_OnPreCommand, I_OnPostCommand, I_OnRestart, I_OnShutdown, I_OnSignal,
I_OnServerQuit, I_OnTopicUpdated,
I_OnEncrypt, I_OnDecrypt,
@@ -1205,8 +1202,7 @@ class CoreExport ModuleManager
*/
static void ClearCallBacks(Module *m);
- /** Unloading all modules, NEVER call this when Anope isn't shutting down.
- * Ever.
+ /** Unloading all modules except the protocol module.
*/
static void UnloadAll();
diff --git a/include/services.h b/include/services.h
index 896f7bf83..f329f99ef 100644
--- a/include/services.h
+++ b/include/services.h
@@ -937,6 +937,19 @@ struct Uplink
bool ipv6;
Uplink(const Anope::string &_host, int _port, const Anope::string &_password, bool _ipv6) : host(_host), port(_port), password(_password), ipv6(_ipv6) { }
+ bool operator==(const Uplink &other) const
+ {
+ if (this->host != other.host)
+ return false;
+ if (this->port != other.port)
+ return false;
+ if (this->password != other.password)
+ return false;
+ if (this->ipv6 != other.ipv6)
+ return false;
+ return true;
+ }
+ inline bool operator!=(const Uplink &other) const { return !(*this == other); }
};
/** A class to process numbered lists (passed to most DEL/LIST/VIEW commands).
diff --git a/include/sockets.h b/include/sockets.h
index bc0c831bf..eca2635e8 100644
--- a/include/sockets.h
+++ b/include/sockets.h
@@ -137,27 +137,34 @@ class CoreExport SocketIO
* @param sz How much to read
* @return Number of bytes received
*/
- virtual int Recv(Socket *s, char *buf, size_t sz) const;
+ virtual int Recv(Socket *s, char *buf, size_t sz);
/** Write something to the socket
* @param s The socket
* @param buf What to write
* @return Number of bytes written
*/
- virtual int Send(Socket *s, const Anope::string &buf) const;
+ virtual int Send(Socket *s, const Anope::string &buf);
/** Accept a connection from a socket
* @param s The socket
+ * @return The new socket
+ */
+ virtual ClientSocket *Accept(ListenSocket *s);
+
+ /** Bind a socket
+ * @param s The socket
+ * @param ip The IP to bind to
+ * @param port The optional port to bind to
*/
- virtual void Accept(ListenSocket *s);
+ virtual void Bind(Socket *s, const Anope::string &ip, int port = 0);
/** Connect the socket
* @param s THe socket
* @param target IP to connect to
* @param port to connect to
- * @param bindip IP to bind to, if any
*/
- virtual void Connect(ConnectionSocket *s, const Anope::string &target, int port, const Anope::string &bindip = "");
+ virtual void Connect(ConnectionSocket *s, const Anope::string &target, int port);
/** Called when the socket is destructing
*/
@@ -173,6 +180,9 @@ class CoreExport Socket : public Flags<SocketFlag, 2>
bool IPv6;
public:
+ /* Sockaddrs for bind() (if it's bound) */
+ sockaddrs bindaddr;
+
/* I/O functions used for this socket */
SocketIO *IO;
@@ -214,6 +224,12 @@ class CoreExport Socket : public Flags<SocketFlag, 2>
*/
bool SetNonBlocking();
+ /** Bind the socket to an ip and port
+ * @param ip The ip
+ * @param port The port
+ */
+ void Bind(const Anope::string &ip, int port = 0);
+
/** Called when there is something to be received for this socket
* @return true on success, false to drop this socket
*/
@@ -291,10 +307,6 @@ class CoreExport BufferedSocket : public Socket
class CoreExport ListenSocket : public Socket
{
- protected:
- /* Sockaddrs for bindip/port */
- sockaddrs listenaddrs;
-
public:
/** Constructor
* @param bindip The IP to bind to
@@ -323,10 +335,10 @@ class CoreExport ListenSocket : public Socket
class CoreExport ConnectionSocket : public BufferedSocket
{
public:
- /* Sockaddrs for bindip (if there is one) */
- sockaddrs bindaddr;
/* Sockaddrs for connection ip/port */
sockaddrs conaddr;
+ /* True if connected */
+ bool connected;
/** Constructor
* @param ipv6 true to use IPv6
@@ -337,9 +349,27 @@ class CoreExport ConnectionSocket : public BufferedSocket
/** Connect the socket
* @param TargetHost The target host to connect to
* @param Port The target port to connect to
- * @param BindHost The host to bind to for connecting
*/
- void Connect(const Anope::string &TargetHost, int Port, const Anope::string &BindHost = "");
+ void Connect(const Anope::string &TargetHost, int Port);
+
+ /** Called when the socket is ready to be written to
+ * @return true on success, false to drop this socket
+ */
+ bool ProcessWrite();
+
+ /** Called when there is an error for this socket
+ * @return true on success, false to drop this socket
+ */
+ void ProcessError();
+
+ /** Called on a successful connect
+ */
+ virtual void OnConnect();
+
+ /** Called when a connection is not successful
+ * @param error The error
+ */
+ virtual void OnError(const Anope::string &error);
};
class CoreExport ClientSocket : public BufferedSocket
diff --git a/modules/core/db_mysql.cpp b/modules/core/db_mysql.cpp
index 193d467da..6a5ba8900 100644
--- a/modules/core/db_mysql.cpp
+++ b/modules/core/db_mysql.cpp
@@ -136,7 +136,7 @@ class DBMySQL : public Module
if (operserv)
this->AddCommand(operserv->Bot(), &commandsqlsync);
- if (uplink_server)
+ if (CurrentUplink)
OnServerConnect();
}
diff --git a/modules/core/os_restart.cpp b/modules/core/os_restart.cpp
index bda2d861c..196d0a3ab 100644
--- a/modules/core/os_restart.cpp
+++ b/modules/core/os_restart.cpp
@@ -26,7 +26,7 @@ class CommandOSRestart : public Command
{
User *u = source.u;
quitmsg = "RESTART command received from " + u->nick;
- do_restart_services();
+ quitting = save_data = restarting = true;
return MOD_CONT;
}
diff --git a/modules/core/os_shutdown.cpp b/modules/core/os_shutdown.cpp
index c67d7acb2..35f76f0c9 100644
--- a/modules/core/os_shutdown.cpp
+++ b/modules/core/os_shutdown.cpp
@@ -26,7 +26,7 @@ class CommandOSShutdown : public Command
{
User *u = source.u;
quitmsg = "SHUTDOWN command received from " + u->nick;
- shutting_down = true;
+ quitting = save_data = true;
return MOD_CONT;
}
diff --git a/modules/extra/m_ssl.cpp b/modules/extra/m_ssl.cpp
index da6361769..30e548150 100644
--- a/modules/extra/m_ssl.cpp
+++ b/modules/extra/m_ssl.cpp
@@ -28,9 +28,16 @@ class MySSLService : public SSLService
class SSLSocketIO : public SocketIO
{
+ /** Check whether this socket has a pending connect() or accept()
+ * @return 0 if neither, -1 if connect/accept fails, -2 to wait more
+ */
+ int CheckState();
+
public:
/* The SSL socket for this socket */
SSL *sslsock;
+ /* -1 if not, 0 if waiting, 1 if true */
+ int connected, accepted;
/** Constructor
*/
@@ -42,27 +49,27 @@ class SSLSocketIO : public SocketIO
* @param sz How much to read
* @return Number of bytes received
*/
- int Recv(Socket *s, char *buf, size_t sz) const;
+ int Recv(Socket *s, char *buf, size_t sz);
/** Really write something to the socket
* @param s The socket
* @param buf What to write
* @return Number of bytes written
*/
- int Send(Socket *s, const Anope::string &buf) const;
+ int Send(Socket *s, const Anope::string &buf);
/** Accept a connection from a socket
* @param s The socket
+ * @return The new socket
*/
- void Accept(ListenSocket *s);
+ ClientSocket *Accept(ListenSocket *s);
/** Connect the socket
* @param s THe socket
* @param target IP to connect to
* @param port to connect to
- * @param bindip IP to bind to, if any
*/
- void Connect(ConnectionSocket *s, const Anope::string &target, int port, const Anope::string &bindip = "");
+ void Connect(ConnectionSocket *s, const Anope::string &target, int port);
/** Called when the socket is destructing
*/
@@ -144,41 +151,27 @@ class SSLModule : public Module
~SSLModule()
{
+ for (std::map<int, Socket *>::const_iterator it = SocketEngine::Sockets.begin(), it_end = SocketEngine::Sockets.end(); it != it_end;)
+ {
+ Socket *s = it->second;
+ ++it;
+
+ if (dynamic_cast<SSLSocketIO *>(s->IO))
+ delete s;
+ }
+
SSL_CTX_free(client_ctx);
SSL_CTX_free(server_ctx);
}
- EventReturn OnPreServerConnect(Uplink *u, int Number)
+ void OnPreServerConnect()
{
ConfigReader config;
- if (config.ReadFlag("uplink", "ssl", "no", Number - 1))
+ if (config.ReadFlag("uplink", "ssl", "no", CurrentUplink))
{
- DNSRecord req = DNSManager::BlockingQuery(uplink_server->host, uplink_server->ipv6 ? DNS_QUERY_AAAA : DNS_QUERY_A);
-
- if (!req)
- Log() << "Unable to connect to server " << uplink_server->host << ":" << uplink_server->port << " using SSL: Invalid hostname/IP";
- else
- {
- try
- {
- new UplinkSocket(uplink_server->ipv6);
- this->service.Init(UplinkSock);
- UplinkSock->Connect(req.result, uplink_server->port, Config->LocalHost);
-
- Log() << "Connected to server " << Number << " (" << u->host << ":" << u->port << ") with SSL";
- return EVENT_ALLOW;
- }
- catch (const SocketException &ex)
- {
- Log() << "Unable to connect with SSL to server " << Number << " (" << u->host << ":" << u->port << "), " << ex.GetReason();
- }
- }
-
- return EVENT_STOP;
+ this->service.Init(UplinkSock);
}
-
- return EVENT_CONTINUE;
}
};
@@ -194,39 +187,67 @@ void MySSLService::Init(Socket *s)
s->IO = new SSLSocketIO();
}
-SSLSocketIO::SSLSocketIO()
+int SSLSocketIO::CheckState()
+{
+ if (this->connected == 0 || this->accepted == 0)
+ {
+ int ret;
+ if (this->connected == 0)
+ ret = SSL_connect(this->sslsock);
+ else if (this->accepted == 0)
+ ret = SSL_accept(this->sslsock);
+ if (ret <= 0)
+ {
+ int error = SSL_get_error(this->sslsock, ret);
+
+ if (ret == -1 && (error == SSL_ERROR_WANT_READ || error == SSL_ERROR_WANT_WRITE))
+ // Wait more
+ return -2;
+ return -1;
+ }
+
+ if (this->connected == 0)
+ this->connected = 1;
+ else if (this->accepted == 0)
+ this->accepted = 1;
+ }
+
+ return 0;
+}
+
+SSLSocketIO::SSLSocketIO() : connected(-1), accepted(-1)
{
this->sslsock = NULL;
}
-int SSLSocketIO::Recv(Socket *s, char *buf, size_t sz) const
+int SSLSocketIO::Recv(Socket *s, char *buf, size_t sz)
{
- int i = SSL_read(this->sslsock, buf, sz);
+ int i = this->CheckState();
+ if (i < 0)
+ return i;
+
+ i = SSL_read(this->sslsock, buf, sz);
TotalRead += i;
return i;
}
-int SSLSocketIO::Send(Socket *s, const Anope::string &buf) const
+int SSLSocketIO::Send(Socket *s, const Anope::string &buf)
{
- int i = SSL_write(this->sslsock, buf.c_str(), buf.length());
+ int i = this->CheckState();
+ if (i < 0)
+ return i;
+
+ i = SSL_write(this->sslsock, buf.c_str(), buf.length());
TotalWritten += i;
return i;
}
-void SSLSocketIO::Accept(ListenSocket *s)
+ClientSocket *SSLSocketIO::Accept(ListenSocket *s)
{
- sockaddrs conaddr;
-
- socklen_t size = conaddr.size();
- int newsock = accept(s->GetFD(), &conaddr.sa, &size);
-
-#ifndef INVALID_SOCKET
-# define INVALID_SOCKET -1
-#endif
- if (newsock <= 0 || newsock == INVALID_SOCKET)
- throw SocketException("Unable to accept SSL socket: " + Anope::LastError());
-
- ClientSocket *newsocket = s->OnAccept(newsock, conaddr);
+ if (s->IO == &normalSocketIO)
+ throw SocketException("Attempting to accept on uninitialized socket with SSL");
+
+ ClientSocket *newsocket = normalSocketIO.Accept(s);
me->service.Init(newsocket);
SSLSocketIO *IO = debug_cast<SSLSocketIO *>(newsocket->IO);
@@ -236,25 +257,22 @@ void SSLSocketIO::Accept(ListenSocket *s)
SSL_set_accept_state(IO->sslsock);
- if (!SSL_set_fd(IO->sslsock, newsock))
+ if (!SSL_set_fd(IO->sslsock, newsocket->GetFD()))
throw SocketException("Unable to set SSL fd");
- int ret = SSL_accept(IO->sslsock);
- if (ret <= 0)
- {
- int error = SSL_get_error(IO->sslsock, ret);
-
- if (ret != -1 || (error != SSL_ERROR_WANT_READ && error != SSL_ERROR_WANT_READ))
- throw SocketException("Unable to accept new SSL connection: " + Anope::string(ERR_error_string(ERR_get_error(), NULL)));
- }
+ IO->accepted = 0;
+ if (this->CheckState() == -1)
+ throw SocketException("Unable to accept new SSL connection: " + Anope::string(ERR_error_string(ERR_get_error(), NULL)));
+
+ return newsocket;
}
-void SSLSocketIO::Connect(ConnectionSocket *s, const Anope::string &TargetHost, int Port, const Anope::string &BindHost)
+void SSLSocketIO::Connect(ConnectionSocket *s, const Anope::string &target, int port)
{
if (s->IO == &normalSocketIO)
- throw SocketException("Attempting to connect uninitialized socket with SQL");
+ throw SocketException("Attempting to connect uninitialized socket with SSL");
- normalSocketIO.Connect(s, TargetHost, Port, BindHost);
+ normalSocketIO.Connect(s, target, port);
SSLSocketIO *IO = debug_cast<SSLSocketIO *>(s->IO);
@@ -265,15 +283,9 @@ void SSLSocketIO::Connect(ConnectionSocket *s, const Anope::string &TargetHost,
if (!SSL_set_fd(IO->sslsock, s->GetFD()))
throw SocketException("Unable to set SSL fd");
- int ret = SSL_connect(IO->sslsock);
-
- if (ret <= 0)
- {
- int error = SSL_get_error(IO->sslsock, ret);
-
- if (ret != -1 || (error != SSL_ERROR_WANT_READ && error != SSL_ERROR_WANT_READ))
- throw SocketException("Unable to connect to server: " + Anope::string(ERR_error_string(ERR_get_error(), NULL)));
- }
+ IO->connected = 0;
+ if (this->CheckState() == -1)
+ throw SocketException("Unable to connect to server: " + Anope::string(ERR_error_string(ERR_get_error(), NULL)));
}
void SSLSocketIO::Destroy()
diff --git a/modules/extra/m_xmlrpc.cpp b/modules/extra/m_xmlrpc.cpp
index 8c0723c42..bba72c2f5 100644
--- a/modules/extra/m_xmlrpc.cpp
+++ b/modules/extra/m_xmlrpc.cpp
@@ -2,6 +2,8 @@
#include "ssl.h"
#include "xmlrpc.h"
+std::vector<XMLRPCListenSocket *> listen_sockets;
+
class MyXMLRPCClientSocket : public XMLRPCClientSocket
{
/* Used to skip the (optional) HTTP header, which we really don't care about */
@@ -85,7 +87,17 @@ class MyXMLRPCClientSocket : public XMLRPCClientSocket
class MyXMLRPCListenSocket : public XMLRPCListenSocket
{
public:
- MyXMLRPCListenSocket(const Anope::string &bindip, int port, bool ipv6, const Anope::string &u, const Anope::string &p, const std::vector<Anope::string> &a) : XMLRPCListenSocket(bindip, port, ipv6, u, p, a) { }
+ MyXMLRPCListenSocket(const Anope::string &bindip, int port, bool ipv6, const Anope::string &u, const Anope::string &p, const std::vector<Anope::string> &a) : XMLRPCListenSocket(bindip, port, ipv6, u, p, a)
+ {
+ listen_sockets.push_back(this);
+ }
+
+ ~MyXMLRPCListenSocket()
+ {
+ std::vector<XMLRPCListenSocket *>::iterator it = std::find(listen_sockets.begin(), listen_sockets.end(), this);
+ if (it != listen_sockets.end())
+ listen_sockets.erase(it);
+ }
ClientSocket *OnAccept(int fd, const sockaddrs &addr)
{
@@ -208,7 +220,6 @@ class ModuleXMLRPC;
static ModuleXMLRPC *me;
class ModuleXMLRPC : public Module
{
- std::vector<MyXMLRPCListenSocket *> listen_sockets;
service_reference<SSLService> sslref;
public:
@@ -229,15 +240,16 @@ class ModuleXMLRPC : public Module
~ModuleXMLRPC()
{
/* Clean up our sockets and our listening sockets */
- for (std::map<int, Socket *>::const_iterator it = SocketEngine::Sockets.begin(), it_end = SocketEngine::Sockets.end(); it != it_end; ++it)
+ for (std::map<int, Socket *>::const_iterator it = SocketEngine::Sockets.begin(), it_end = SocketEngine::Sockets.end(); it != it_end;)
{
Socket *s = it->second;
+ ++it;
if (s->Type == SOCKTYPE_CLIENT)
{
ClientSocket *cs = debug_cast<ClientSocket *>(s);
- for (unsigned i = 0; i < this->listen_sockets.size(); ++i)
- if (cs->LS == this->listen_sockets[i])
+ for (unsigned i = 0; i < listen_sockets.size(); ++i)
+ if (cs->LS == listen_sockets[i])
{
delete cs;
break;
@@ -245,18 +257,18 @@ class ModuleXMLRPC : public Module
}
}
- for (unsigned i = 0; i < this->listen_sockets.size(); ++i)
- delete this->listen_sockets[i];
- this->listen_sockets.clear();
+ for (unsigned i = 0; i < listen_sockets.size(); ++i)
+ delete listen_sockets[i];
+ listen_sockets.clear();
}
void OnReload()
{
ConfigReader config;
- for (unsigned i = 0; i < this->listen_sockets.size(); ++i)
- delete this->listen_sockets[i];
- this->listen_sockets.clear();
+ for (unsigned i = 0; i < listen_sockets.size(); ++i)
+ delete listen_sockets[i];
+ listen_sockets.clear();
for (int i = 0; i < config.Enumerate("m_xmlrpc"); ++i)
{
@@ -282,10 +294,7 @@ class ModuleXMLRPC : public Module
{
MyXMLRPCListenSocket *xmls = new MyXMLRPCListenSocket(bindip, port, ipv6, username, password, allowed_vector);
if (ssl)
- {
sslref->Init(xmls);
- }
- this->listen_sockets.push_back(xmls);
}
catch (const SocketException &ex)
{
diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp
index 92aee74fb..29f16004e 100644
--- a/modules/protocol/bahamut.cpp
+++ b/modules/protocol/bahamut.cpp
@@ -232,7 +232,7 @@ class BahamutIRCdProto : public IRCDProto
void SendConnect()
{
- bahamut_cmd_pass(uplink_server->password);
+ bahamut_cmd_pass(Config->Uplinks[CurrentUplink]->password);
bahamut_cmd_capab();
SendServer(Me);
bahamut_cmd_svinfo();
diff --git a/modules/protocol/inspircd-ts6.h b/modules/protocol/inspircd-ts6.h
index d76dc27c2..cf93865f8 100644
--- a/modules/protocol/inspircd-ts6.h
+++ b/modules/protocol/inspircd-ts6.h
@@ -124,7 +124,7 @@ class InspIRCdTS6Proto : public IRCDProto
/* SERVER services-dev.chatspike.net password 0 :Description here */
void SendServer(const Server *server)
{
- send_cmd("", "SERVER %s %s %d %s :%s", server->GetName().c_str(), uplink_server ? uplink_server->password.c_str() : "none", server->GetHops(), server->GetSID().c_str(), server->GetDescription().c_str());
+ send_cmd("", "SERVER %s %s %d %s :%s", server->GetName().c_str(), Config->Uplinks[CurrentUplink]->password.c_str(), server->GetHops(), server->GetSID().c_str(), server->GetDescription().c_str());
}
/* JOIN */
diff --git a/modules/protocol/inspircd11.cpp b/modules/protocol/inspircd11.cpp
index 5ab55ab07..a382d4006 100644
--- a/modules/protocol/inspircd11.cpp
+++ b/modules/protocol/inspircd11.cpp
@@ -199,7 +199,7 @@ class InspIRCdProto : public IRCDProto
void SendConnect()
{
- inspircd_cmd_pass(uplink_server->password);
+ inspircd_cmd_pass(Config->Uplinks[CurrentUplink]->password);
SendServer(Me);
send_cmd("", "BURST");
Module *enc = ModuleManager::FindFirstOf(ENCRYPTION);
diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp
index 04095e5a2..5e6c67781 100644
--- a/modules/protocol/plexus.cpp
+++ b/modules/protocol/plexus.cpp
@@ -157,7 +157,7 @@ class PlexusProto : public IRCDProto
void SendConnect()
{
- plexus_cmd_pass(uplink_server->password);
+ plexus_cmd_pass(Config->Uplinks[CurrentUplink]->password);
plexus_cmd_capab();
/* Make myself known to myself in the serverlist */
SendServer(Me);
diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp
index d6cfc761f..2833c52b7 100644
--- a/modules/protocol/ratbox.cpp
+++ b/modules/protocol/ratbox.cpp
@@ -160,7 +160,7 @@ class RatboxProto : public IRCDProto
void SendConnect()
{
- ratbox_cmd_pass(uplink_server->password);
+ ratbox_cmd_pass(Config->Uplinks[CurrentUplink]->password);
ratbox_cmd_capab();
/* Make myself known to myself in the serverlist */
SendServer(Me);
diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp
index cb7a54d61..e07b97af0 100644
--- a/modules/protocol/unreal.cpp
+++ b/modules/protocol/unreal.cpp
@@ -228,7 +228,7 @@ class UnrealIRCdProto : public IRCDProto
void SendConnect()
{
unreal_cmd_capab();
- unreal_cmd_pass(uplink_server->password);
+ unreal_cmd_pass(Config->Uplinks[CurrentUplink]->password);
SendServer(Me);
}
diff --git a/src/config.cpp b/src/config.cpp
index 671cf3ed7..7d3efcb91 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -563,7 +563,7 @@ bool InitUplinks(ServerConfig *config, const Anope::string &)
{
if (!config->Uplinks.empty())
{
- std::list<Uplink *>::iterator curr_uplink = config->Uplinks.begin(), end_uplink = config->Uplinks.end();
+ std::vector<Uplink *>::iterator curr_uplink = config->Uplinks.begin(), end_uplink = config->Uplinks.end();
for (; curr_uplink != end_uplink; ++curr_uplink)
delete *curr_uplink;
}
@@ -1033,7 +1033,6 @@ ConfigItems::ConfigItems(ServerConfig *conf)
{"options", "mlock", "+nrt", new ValueContainerString(&conf->MLock), DT_STRING, NoValidation},
{"options", "nomlock", "", new ValueContainerString(&conf->NoMLock), DT_STRING, NoValidation},
{"options", "botmodes", "", new ValueContainerString(&conf->BotModes), DT_STRING, NoValidation},
- {"options", "maxretries", "10", new ValueContainerUInt(&conf->MaxRetries), DT_UINTEGER, NoValidation},
{"options", "retrywait", "60", new ValueContainerInt(&conf->RetryWait), DT_INTEGER, ValidateNotZero},
{"options", "hideprivilegedcommands", "no", new ValueContainerBool(&conf->HidePrivilegedCommands), DT_BOOLEAN, NoValidation},
{"nickserv", "nick", "NickServ", new ValueContainerString(&conf->s_NickServ), DT_STRING | DT_NORELOAD, ValidateNotEmpty},
diff --git a/src/dns.cpp b/src/dns.cpp