- Notifier(int newfd, char* ip, Server* S) : InspSocket(newfd, ip), Srv(S)
- {
- log(DEBUG,"Constructor of new socket");
- }
-
- /* Using getsockname and ntohs, we can determine which port number we were allocated */
- int GetPort()
- {
- return ntohs(sock_us.sin_port);
- }
-
- virtual int OnIncomingConnection(int newsock, char* ip)
- {
- log(DEBUG,"Inbound connection on fd %d!",newsock);
- Notifier* n = new Notifier(newsock, ip, Srv);
- Srv->AddSocket(n);
- return true;
+void LoadDatabases(ConfigReader* conf, InspIRCd* ServerInstance, ModuleSQL* Parent)
+{
+ Parent->ConnMutex.Lock();
+ ClearOldConnections(conf);
+ for (int j =0; j < conf->Enumerate("database"); j++)
+ {
+ SQLhost host;
+ host.id = conf->ReadValue("database", "id", j);
+ host.host = conf->ReadValue("database", "hostname", j);
+ host.port = conf->ReadInteger("database", "port", j, true);
+ host.name = conf->ReadValue("database", "name", j);
+ host.user = conf->ReadValue("database", "username", j);
+ host.pass = conf->ReadValue("database", "password", j);
+ host.ssl = conf->ReadFlag("database", "ssl", j);
+
+ if (HasHost(host))
+ continue;
+
+ if (!host.id.empty() && !host.host.empty() && !host.name.empty() && !host.user.empty() && !host.pass.empty())
+ {
+ SQLConnection* ThisSQL = new SQLConnection(host, Parent);
+ Connections[host.id] = ThisSQL;
+ }