Skip to content
Snippets Groups Projects
Unverified Commit 33bc11f5 authored by Bensong Liu's avatar Bensong Liu
Browse files

compiles

parent 0b1df4e0
No related branches found
No related tags found
No related merge requests found
...@@ -15,14 +15,20 @@ class Forwarder { ...@@ -15,14 +15,20 @@ class Forwarder {
public: public:
Forwarder(const rlib::string &inboundConfig, const rlib::string &outboundConfig) { Forwarder(const rlib::string &inboundConfig, const rlib::string &outboundConfig) {
if (inboundConfig.starts_with("plain")) if (inboundConfig.starts_with("plain"))
ptrInbound = new Protocols::PlainInbound(inboundConfig); ptrInbound = new Protocols::PlainInbound;
else if (inboundConfig.starts_with("misc")) else if (inboundConfig.starts_with("misc"))
ptrInbound = nullptr; // TODO ptrInbound = nullptr; // TODO
else
throw std::invalid_argument("Unknown protocol in inboundConfig " + inboundConfig);
ptrInbound->loadConfig(inboundConfig);
if (outboundConfig.starts_with("plain")) if (outboundConfig.starts_with("plain"))
ptrOutbound = nullptr; // TODO ptrOutbound = new Protocols::PlainOutbound;
else if (outboundConfig.starts_with("misc")) else if (outboundConfig.starts_with("misc"))
ptrOutbound = nullptr; // TODO ptrOutbound = nullptr; // TODO
else
throw std::invalid_argument("Unknown protocol in outboundConfig " + outboundConfig);
ptrOutbound->loadConfig(outboundConfig);
} }
~Forwarder() { ~Forwarder() {
......
...@@ -22,9 +22,6 @@ namespace Protocols { ...@@ -22,9 +22,6 @@ namespace Protocols {
// senderId is "$ip@$port", for example, `fe80:8100::1@1080`. // senderId is "$ip@$port", for example, `fe80:8100::1@1080`.
// Note: this interface works for both TCP and UDP. // Note: this interface works for both TCP and UDP.
struct BaseOutbound : rlib::noncopyable { struct BaseOutbound : rlib::noncopyable {
BaseOutbound(string outboundConfig) {
loadConfig(outboundConfig);
}
virtual ~BaseOutbound() = default; virtual ~BaseOutbound() = default;
// Init data structures. // Init data structures.
...@@ -42,9 +39,6 @@ namespace Protocols { ...@@ -42,9 +39,6 @@ namespace Protocols {
}; };
struct BaseInbound : rlib::noncopyable { struct BaseInbound : rlib::noncopyable {
BaseInbound(string inboundConfig) {
loadConfig(inboundConfig);
}
virtual ~BaseInbound() = default; virtual ~BaseInbound() = default;
// Init data structures. // Init data structures.
......
...@@ -34,7 +34,6 @@ namespace Protocols { ...@@ -34,7 +34,6 @@ namespace Protocols {
class PlainInbound : public BaseInbound { class PlainInbound : public BaseInbound {
public: public:
using BaseInbound::BaseInbound;
virtual void loadConfig(string config) override { virtual void loadConfig(string config) override {
auto ar = rlib::string(config).split('@'); // Also works for ipv6. auto ar = rlib::string(config).split('@'); // Also works for ipv6.
if (ar.size() != 3) if (ar.size() != 3)
...@@ -104,7 +103,6 @@ namespace Protocols { ...@@ -104,7 +103,6 @@ namespace Protocols {
class PlainOutbound : public BaseOutbound { class PlainOutbound : public BaseOutbound {
public: public:
using BaseOutbound::BaseOutbound;
virtual void loadConfig(string config) override { virtual void loadConfig(string config) override {
auto ar = rlib::string(config).split('@'); // Also works for ipv6. auto ar = rlib::string(config).split('@'); // Also works for ipv6.
if (ar.size() != 3) if (ar.size() != 3)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment