diff --git a/src/forwarder.hpp b/src/forwarder.hpp index 851d87c8386b26af71697c0bb5fe3ca66c033c3b..5fa80949383a47f745ac3ebe3842eb07e65788a6 100644 --- a/src/forwarder.hpp +++ b/src/forwarder.hpp @@ -15,14 +15,20 @@ class Forwarder { public: Forwarder(const rlib::string &inboundConfig, const rlib::string &outboundConfig) { if (inboundConfig.starts_with("plain")) - ptrInbound = new Protocols::PlainInbound(inboundConfig); + ptrInbound = new Protocols::PlainInbound; else if (inboundConfig.starts_with("misc")) ptrInbound = nullptr; // TODO + else + throw std::invalid_argument("Unknown protocol in inboundConfig " + inboundConfig); + ptrInbound->loadConfig(inboundConfig); if (outboundConfig.starts_with("plain")) - ptrOutbound = nullptr; // TODO + ptrOutbound = new Protocols::PlainOutbound; else if (outboundConfig.starts_with("misc")) ptrOutbound = nullptr; // TODO + else + throw std::invalid_argument("Unknown protocol in outboundConfig " + outboundConfig); + ptrOutbound->loadConfig(outboundConfig); } ~Forwarder() { diff --git a/src/protocols/base.hpp b/src/protocols/base.hpp index 2a88f1a99e00b6644284550e587145d3f3390b56..d0eda6955a13952cd032b518238215cfe04cf3ab 100644 --- a/src/protocols/base.hpp +++ b/src/protocols/base.hpp @@ -22,9 +22,6 @@ namespace Protocols { // senderId is "$ip@$port", for example, `fe80:8100::1@1080`. // Note: this interface works for both TCP and UDP. struct BaseOutbound : rlib::noncopyable { - BaseOutbound(string outboundConfig) { - loadConfig(outboundConfig); - } virtual ~BaseOutbound() = default; // Init data structures. @@ -42,9 +39,6 @@ namespace Protocols { }; struct BaseInbound : rlib::noncopyable { - BaseInbound(string inboundConfig) { - loadConfig(inboundConfig); - } virtual ~BaseInbound() = default; // Init data structures. diff --git a/src/protocols/plain.hpp b/src/protocols/plain.hpp index 71194bc02d67fa50001d1f721decbe0086fa7e29..d89fce40ae8616e8490ba009650dc1e6aea6285c 100644 --- a/src/protocols/plain.hpp +++ b/src/protocols/plain.hpp @@ -34,7 +34,6 @@ namespace Protocols { class PlainInbound : public BaseInbound { public: - using BaseInbound::BaseInbound; virtual void loadConfig(string config) override { auto ar = rlib::string(config).split('@'); // Also works for ipv6. if (ar.size() != 3) @@ -104,7 +103,6 @@ namespace Protocols { class PlainOutbound : public BaseOutbound { public: - using BaseOutbound::BaseOutbound; virtual void loadConfig(string config) override { auto ar = rlib::string(config).split('@'); // Also works for ipv6. if (ar.size() != 3)