From 33bc11f55f778ef587d71685c5d0dccc3be9c9ea Mon Sep 17 00:00:00 2001 From: Bensong Liu <bensl@microsoft.com> Date: Wed, 29 Jul 2020 16:58:37 +0800 Subject: [PATCH] compiles --- src/forwarder.hpp | 10 ++++++++-- src/protocols/base.hpp | 6 ------ src/protocols/plain.hpp | 2 -- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/forwarder.hpp b/src/forwarder.hpp index 851d87c..5fa8094 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 2a88f1a..d0eda69 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 71194bc..d89fce4 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) -- GitLab