mirror of
https://github.com/anope/anope.git
synced 2026-07-02 20:43:12 +02:00
Allow enabling ssl on a per-uplink basis
This commit is contained in:
+7
-1
@@ -91,10 +91,16 @@ uplink
|
||||
host = "localhost"
|
||||
|
||||
/*
|
||||
* Enable if Services should connect using IPv6
|
||||
* Enable if Services should connect using IPv6.
|
||||
*/
|
||||
ipv6 = no
|
||||
|
||||
/*
|
||||
* Enable if Services should connect using SSL.
|
||||
* You must have m_ssl loaded for this to work.
|
||||
*/
|
||||
ssl = no
|
||||
|
||||
/*
|
||||
* The port to connect to.
|
||||
* The IRCd *MUST* be configured to listen on this port, and to accept
|
||||
|
||||
+4
-2
@@ -577,10 +577,12 @@ class CoreExport Module
|
||||
*/
|
||||
virtual void OnChanExpire(const char *chname) { }
|
||||
|
||||
/** Called before anope connects to its uplink
|
||||
/** 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
|
||||
*/
|
||||
virtual EventReturn OnPreServerConnect() { return EVENT_CONTINUE; }
|
||||
virtual EventReturn OnPreServerConnect(Uplink *u, int Number) { return EVENT_CONTINUE; }
|
||||
|
||||
/** Called when Anope connects to its uplink
|
||||
*/
|
||||
|
||||
+11
-7
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user