diff options
author | Sadie Powell <sadie@witchery.services> | 2022-12-15 13:07:22 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2022-12-17 11:50:38 +0000 |
commit | dfdcd3021a482182827ba00782acd5a53442d21a (patch) | |
tree | a1fc48af8de2c732a6222c7db9e1c9018de0b785 /src/config.cpp | |
parent | 5fa3d8f9297f50e25a7bad6a9bde91b9024330de (diff) |
Add support for linking over UNIX sockets.
Diffstat (limited to 'src/config.cpp')
-rw-r--r-- | src/config.cpp | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/config.cpp b/src/config.cpp index 0d1900268..0503340b0 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -193,19 +193,33 @@ Conf::Conf() : Block(""), EmptyBlock("") { Block *uplink = this->GetBlock("uplink", i); - const Anope::string &host = uplink->Get<const Anope::string>("host"); - bool ipv6 = uplink->Get<bool>("ipv6"); - int port = uplink->Get<int>("port"); - const Anope::string &password = uplink->Get<const Anope::string>("password"); + int protocol; + const Anope::string &protocolstr = uplink->Get<const Anope::string>("protocol", "ipv4"); + if (protocolstr == "ipv4") + protocol = AF_INET; + else if (protocolstr == "ipv6") + protocol = AF_INET6; + else if (protocolstr == "unix") + protocol = AF_UNIX; + else + throw ConfigException("uplink:protocol must be set to ipv4, ipv6, or unix"); + const Anope::string &host = uplink->Get<const Anope::string>("host"); ValidateNotEmptyOrSpaces("uplink", "host", host); - ValidateNotZero("uplink", "port", port); - ValidateNotEmptyOrSpaces("uplink", "password", password); - if (password.find(' ') != Anope::string::npos || password[0] == ':') + int port = 0; + if (protocol != AF_UNIX) + { + ValidateNotZero("uplink", "port", port); + port = uplink->Get<int>("port"); + } + + const Anope::string &password = uplink->Get<const Anope::string>("password"); + ValidateNotEmptyOrSpaces("uplink", "password", password); + if (password[0] == ':') throw ConfigException("uplink:password is not valid"); - this->Uplinks.emplace_back(host, port, password, ipv6); + this->Uplinks.emplace_back(host, port, password, protocol); } for (int i = 0; i < this->CountBlock("module"); ++i) |