summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.c18
-rw-r--r--src/modules/ssl/m_ssl.cpp18
2 files changed, 19 insertions, 17 deletions
diff --git a/src/main.c b/src/main.c
index 4c91fcde2..68423e4ec 100644
--- a/src/main.c
+++ b/src/main.c
@@ -389,19 +389,21 @@ std::string GetFullProgDir(char *argv0)
static bool Connect()
{
- EventReturn MOD_RESULT;
- FOREACH_RESULT(I_OnPreServerConnect, OnPreServerConnect());
- if (MOD_RESULT != EVENT_CONTINUE)
- {
- return (MOD_RESULT == EVENT_ALLOW ? true : false);
- }
-
/* Connect to the remote server */
int servernum = 1;
for (std::list<Uplink *>::iterator curr_uplink = Config.Uplinks.begin(); curr_uplink != Config.Uplinks.end(); ++curr_uplink, ++servernum)
{
uplink_server = *curr_uplink;
+ EventReturn MOD_RESULT;
+ FOREACH_RESULT(I_OnPreServerConnect, OnPreServerConnect(*curr_uplink, servernum));
+ if (MOD_RESULT != EVENT_CONTINUE)
+ {
+ if (MOD_RESULT == EVENT_STOP)
+ break;
+ return true;
+ }
+
try
{
new UplinkSocket(uplink_server->host, uplink_server->port, Config.LocalHost ? Config.LocalHost : "", uplink_server->ipv6);
@@ -416,6 +418,8 @@ static bool Connect()
return true;
}
+ uplink_server = NULL;
+
return false;
}
diff --git a/src/modules/ssl/m_ssl.cpp b/src/modules/ssl/m_ssl.cpp
index 075352551..be3e5da1f 100644
--- a/src/modules/ssl/m_ssl.cpp
+++ b/src/modules/ssl/m_ssl.cpp
@@ -122,28 +122,26 @@ class SSLModule : public Module
SSL_CTX_free(ctx);
}
- EventReturn OnPreServerConnect()
+ EventReturn OnPreServerConnect(Uplink *u, int Number)
{
- int servernum = 1;
- for (std::list<Uplink *>::iterator curr_uplink = Config.Uplinks.begin(); curr_uplink != Config.Uplinks.end(); ++curr_uplink, ++servernum)
- {
- uplink_server = *curr_uplink;
+ ConfigReader config;
+ if (config.ReadFlag("uplink", "ssl", "no", Number - 1))
+ {
try
{
- new SSLSocket(uplink_server->host, uplink_server->port, Config.LocalHost ? Config.LocalHost : "", uplink_server->ipv6);
+ new SSLSocket(u->host, u->port, Config.LocalHost ? Config.LocalHost : "", u->ipv6);
+ Alog() << "Connected to Server " << Number << " (" << u->host << ":" << u->port << ")";
}
catch (SocketException& ex)
{
- Alog() << "Unable to connect to server" << servernum << " (" << uplink_server->host << ":" << uplink_server->port << "), " << ex.GetReason();
- continue;
+ Alog() << "Unable to connect with SSL to server" << Number << " (" << u->host << ":" << u->port << "), " << ex.GetReason();
}
- Alog() << "Connected to Server " << servernum << " (" << uplink_server->host << ":" << uplink_server->port << ")";
return EVENT_ALLOW;
}
- return EVENT_STOP;
+ return EVENT_CONTINUE;
}
};