diff options
author | Adam <Adam@anope.org> | 2013-05-05 01:55:04 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2013-05-05 01:55:04 -0400 |
commit | 1d0bb9b26b7ad58ab0bf979ac046f4511b3bf12b (patch) | |
tree | 4486f0784bdf050fd7eb225c0cb9df352ce1f45a /src/uplink.cpp | |
parent | 781defb7076ddfddf723ca08cd0a518b6657b64f (diff) |
Rework the config file reader to be much more flexible and move many configuration directives to the actual modules they are used in.
Diffstat (limited to 'src/uplink.cpp')
-rw-r--r-- | src/uplink.cpp | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/uplink.cpp b/src/uplink.cpp index f8841c58f..ff90ee53c 100644 --- a/src/uplink.cpp +++ b/src/uplink.cpp @@ -31,7 +31,7 @@ class ReconnectTimer : public Timer } catch (const SocketException &ex) { - Log(LOG_TERMINAL) << "Unable to connect to uplink #" << (Anope::CurrentUplink + 1) << " (" << Config->Uplinks[Anope::CurrentUplink]->host << ":" << Config->Uplinks[Anope::CurrentUplink]->port << "): " << ex.GetReason(); + Log(LOG_TERMINAL) << "Unable to connect to uplink #" << (Anope::CurrentUplink + 1) << " (" << Config->Uplinks[Anope::CurrentUplink].host << ":" << Config->Uplinks[Anope::CurrentUplink].port << "): " << ex.GetReason(); } } }; @@ -41,19 +41,19 @@ void Uplink::Connect() if (static_cast<unsigned>(++Anope::CurrentUplink) >= Config->Uplinks.size()) Anope::CurrentUplink = 0; - ServerConfig::Uplink *u = Config->Uplinks[Anope::CurrentUplink]; + Configuration::Uplink &u = Config->Uplinks[Anope::CurrentUplink]; new UplinkSocket(); - if (!Config->LocalHost.empty()) - UplinkSock->Bind(Config->LocalHost); + if (!Config->GetBlock("serverinfo")->Get<const Anope::string &>("localhost").empty()) + UplinkSock->Bind(Config->GetBlock("serverinfo")->Get<const Anope::string &>("localhost")); FOREACH_MOD(I_OnPreServerConnect, OnPreServerConnect()); - Anope::string ip = Anope::Resolve(u->host, u->ipv6 ? AF_INET6 : AF_INET); - Log(LOG_TERMINAL) << "Attempting to connect to uplink #" << (Anope::CurrentUplink + 1) << " " << u->host << " (" << ip << "), port " << u->port; - UplinkSock->Connect(ip, u->port); + Anope::string ip = Anope::Resolve(u.host, u.ipv6 ? AF_INET6 : AF_INET); + Log(LOG_TERMINAL) << "Attempting to connect to uplink #" << (Anope::CurrentUplink + 1) << " " << u.host << " (" << ip << "), port " << u.port; + UplinkSock->Connect(ip, u.port); } -UplinkSocket::UplinkSocket() : Socket(-1, Config->Uplinks[Anope::CurrentUplink]->ipv6), ConnectionSocket(), BufferedSocket() +UplinkSocket::UplinkSocket() : Socket(-1, Config->Uplinks[Anope::CurrentUplink].ipv6), ConnectionSocket(), BufferedSocket() { UplinkSock = this; } @@ -107,9 +107,7 @@ UplinkSocket::~UplinkSocket() } else if (!Anope::Quitting) { - int retry = Config->RetryWait; - if (retry <= 0) - retry = 60; + time_t retry = Config->GetBlock("options")->Get<time_t>("retrywait"); Log() << "Disconnected, retrying in " << retry << " seconds"; new ReconnectTimer(retry); @@ -129,14 +127,14 @@ bool UplinkSocket::ProcessRead() void UplinkSocket::OnConnect() { - Log(LOG_TERMINAL) << "Successfully connected to uplink #" << (Anope::CurrentUplink + 1) << " " << Config->Uplinks[Anope::CurrentUplink]->host << ":" << Config->Uplinks[Anope::CurrentUplink]->port; + Log(LOG_TERMINAL) << "Successfully connected to uplink #" << (Anope::CurrentUplink + 1) << " " << Config->Uplinks[Anope::CurrentUplink].host << ":" << Config->Uplinks[Anope::CurrentUplink].port; IRCD->SendConnect(); FOREACH_MOD(I_OnServerConnect, OnServerConnect()); } void UplinkSocket::OnError(const Anope::string &error) { - Log(LOG_TERMINAL) << "Unable to connect to uplink #" << (Anope::CurrentUplink + 1) << " (" << Config->Uplinks[Anope::CurrentUplink]->host << ":" << Config->Uplinks[Anope::CurrentUplink]->port << ")" << (!error.empty() ? (": " + error) : ""); + Log(LOG_TERMINAL) << "Unable to connect to uplink #" << (Anope::CurrentUplink + 1) << " (" << Config->Uplinks[Anope::CurrentUplink].host << ":" << Config->Uplinks[Anope::CurrentUplink].port << ")" << (!error.empty() ? (": " + error) : ""); } UplinkSocket::Message::Message() : server(NULL), user(NULL) |