summaryrefslogtreecommitdiffhomepage
path: root/wfpctl/src/extras/cli/commands
diff options
context:
space:
mode:
Diffstat (limited to 'wfpctl/src/extras/cli/commands')
-rw-r--r--wfpctl/src/extras/cli/commands/icommand.h17
-rw-r--r--wfpctl/src/extras/cli/commands/list/events.cpp51
-rw-r--r--wfpctl/src/extras/cli/commands/list/events.h25
-rw-r--r--wfpctl/src/extras/cli/commands/list/filters.cpp51
-rw-r--r--wfpctl/src/extras/cli/commands/list/filters.h25
-rw-r--r--wfpctl/src/extras/cli/commands/list/layers.cpp51
-rw-r--r--wfpctl/src/extras/cli/commands/list/layers.h25
-rw-r--r--wfpctl/src/extras/cli/commands/list/providercontexts.cpp51
-rw-r--r--wfpctl/src/extras/cli/commands/list/providercontexts.h25
-rw-r--r--wfpctl/src/extras/cli/commands/list/providers.cpp48
-rw-r--r--wfpctl/src/extras/cli/commands/list/providers.h25
-rw-r--r--wfpctl/src/extras/cli/commands/list/sessions.cpp48
-rw-r--r--wfpctl/src/extras/cli/commands/list/sessions.h25
-rw-r--r--wfpctl/src/extras/cli/commands/list/sublayers.cpp51
-rw-r--r--wfpctl/src/extras/cli/commands/list/sublayers.h25
-rw-r--r--wfpctl/src/extras/cli/commands/monitor/m_events.cpp68
-rw-r--r--wfpctl/src/extras/cli/commands/monitor/m_events.h28
-rw-r--r--wfpctl/src/extras/cli/commands/wfpctl/deinit.cpp35
-rw-r--r--wfpctl/src/extras/cli/commands/wfpctl/deinit.h25
-rw-r--r--wfpctl/src/extras/cli/commands/wfpctl/init.cpp54
-rw-r--r--wfpctl/src/extras/cli/commands/wfpctl/init.h28
-rw-r--r--wfpctl/src/extras/cli/commands/wfpctl/policy.cpp170
-rw-r--r--wfpctl/src/extras/cli/commands/wfpctl/policy.h35
23 files changed, 0 insertions, 986 deletions
diff --git a/wfpctl/src/extras/cli/commands/icommand.h b/wfpctl/src/extras/cli/commands/icommand.h
deleted file mode 100644
index a9503a205b..0000000000
--- a/wfpctl/src/extras/cli/commands/icommand.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#pragma once
-
-#include <string>
-#include <vector>
-
-namespace commands
-{
-
-struct ICommand
-{
- virtual std::wstring name() = 0;
- virtual std::wstring description() = 0;
-
- virtual void handleRequest(const std::vector<std::wstring> &arguments) = 0;
-};
-
-}
diff --git a/wfpctl/src/extras/cli/commands/list/events.cpp b/wfpctl/src/extras/cli/commands/list/events.cpp
deleted file mode 100644
index 4396eff980..0000000000
--- a/wfpctl/src/extras/cli/commands/list/events.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-#include "stdafx.h"
-#include "events.h"
-#include "cli/objectproperties.h"
-#include "cli/filterengineprovider.h"
-#include "cli/propertydecorator.h"
-#include "libwfp/objectenumerator.h"
-
-namespace commands::list
-{
-
-Events::Events(MessageSink messageSink)
- : m_messageSink(messageSink)
-{
-}
-
-std::wstring Events::name()
-{
- return L"events";
-
-}
-
-std::wstring Events::description()
-{
- return L"Provides a listing of all recent events in the system.";
-}
-
-void Events::handleRequest(const std::vector<std::wstring> &arguments)
-{
- if (false == arguments.empty())
- {
- throw std::runtime_error("Unsupported argument(s). Cannot complete request.");
- }
-
- PrettyPrintOptions options;
-
- options.indent = 2;
- options.useSeparator = true;
-
- PropertyDecorator decorator(FilterEngineProvider::Instance().get());
-
- wfp::ObjectEnumerator::Events(*FilterEngineProvider::Instance().get(), [&](const FWPM_NET_EVENT0 &event)
- {
- m_messageSink(L"Event");
-
- PrettyPrintProperties(m_messageSink, options, EventProperties(event, &decorator));
-
- return true;
- });
-}
-
-}
diff --git a/wfpctl/src/extras/cli/commands/list/events.h b/wfpctl/src/extras/cli/commands/list/events.h
deleted file mode 100644
index cc727712f0..0000000000
--- a/wfpctl/src/extras/cli/commands/list/events.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#pragma once
-
-#include "cli/commands/icommand.h"
-#include "cli/util.h"
-
-namespace commands::list
-{
-
-class Events : public ICommand
-{
-public:
-
- Events(MessageSink messageSink);
-
- std::wstring name() override;
- std::wstring description() override;
-
- void handleRequest(const std::vector<std::wstring> &arguments) override;
-
-private:
-
- MessageSink m_messageSink;
-};
-
-}
diff --git a/wfpctl/src/extras/cli/commands/list/filters.cpp b/wfpctl/src/extras/cli/commands/list/filters.cpp
deleted file mode 100644
index 9c7917bf66..0000000000
--- a/wfpctl/src/extras/cli/commands/list/filters.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-#include "stdafx.h"
-#include "filters.h"
-#include "cli/objectproperties.h"
-#include "cli/filterengineprovider.h"
-#include "cli/propertydecorator.h"
-#include "libwfp/objectenumerator.h"
-
-namespace commands::list
-{
-
-Filters::Filters(MessageSink messageSink)
- : m_messageSink(messageSink)
-{
-}
-
-std::wstring Filters::name()
-{
- return L"filters";
-
-}
-
-std::wstring Filters::description()
-{
- return L"Provides a listing of all filters in the system.";
-}
-
-void Filters::handleRequest(const std::vector<std::wstring> &arguments)
-{
- if (false == arguments.empty())
- {
- throw std::runtime_error("Unsupported argument(s). Cannot complete request.");
- }
-
- PrettyPrintOptions options;
-
- options.indent = 2;
- options.useSeparator = true;
-
- PropertyDecorator decorator(FilterEngineProvider::Instance().get());
-
- wfp::ObjectEnumerator::Filters(*FilterEngineProvider::Instance().get(), [&](const FWPM_FILTER0 &filter)
- {
- m_messageSink(L"Filter");
-
- PrettyPrintProperties(m_messageSink, options, FilterProperties(filter, &decorator));
-
- return true;
- });
-}
-
-}
diff --git a/wfpctl/src/extras/cli/commands/list/filters.h b/wfpctl/src/extras/cli/commands/list/filters.h
deleted file mode 100644
index 4c0345f3b3..0000000000
--- a/wfpctl/src/extras/cli/commands/list/filters.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#pragma once
-
-#include "cli/commands/icommand.h"
-#include "cli/util.h"
-
-namespace commands::list
-{
-
-class Filters : public ICommand
-{
-public:
-
- Filters(MessageSink messageSink);
-
- std::wstring name() override;
- std::wstring description() override;
-
- void handleRequest(const std::vector<std::wstring> &arguments) override;
-
-private:
-
- MessageSink m_messageSink;
-};
-
-}
diff --git a/wfpctl/src/extras/cli/commands/list/layers.cpp b/wfpctl/src/extras/cli/commands/list/layers.cpp
deleted file mode 100644
index 3dc4368894..0000000000
--- a/wfpctl/src/extras/cli/commands/list/layers.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-#include "stdafx.h"
-#include "layers.h"
-#include "cli/objectproperties.h"
-#include "cli/filterengineprovider.h"
-#include "cli/propertydecorator.h"
-#include "libwfp/objectenumerator.h"
-
-namespace commands::list
-{
-
-Layers::Layers(MessageSink messageSink)
- : m_messageSink(messageSink)
-{
-}
-
-std::wstring Layers::name()
-{
- return L"layers";
-
-}
-
-std::wstring Layers::description()
-{
- return L"Provides a listing of all layers in the system.";
-}
-
-void Layers::handleRequest(const std::vector<std::wstring> &arguments)
-{
- if (false == arguments.empty())
- {
- throw std::runtime_error("Unsupported argument(s). Cannot complete request.");
- }
-
- PrettyPrintOptions options;
-
- options.indent = 2;
- options.useSeparator = true;
-
- PropertyDecorator decorator(FilterEngineProvider::Instance().get());
-
- wfp::ObjectEnumerator::Layers(*FilterEngineProvider::Instance().get(), [&](const FWPM_LAYER0 &layer)
- {
- m_messageSink(L"Layer");
-
- PrettyPrintProperties(m_messageSink, options, LayerProperties(layer, &decorator));
-
- return true;
- });
-}
-
-}
diff --git a/wfpctl/src/extras/cli/commands/list/layers.h b/wfpctl/src/extras/cli/commands/list/layers.h
deleted file mode 100644
index 92a62c58e0..0000000000
--- a/wfpctl/src/extras/cli/commands/list/layers.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#pragma once
-
-#include "cli/commands/icommand.h"
-#include "cli/util.h"
-
-namespace commands::list
-{
-
-class Layers : public ICommand
-{
-public:
-
- Layers(MessageSink messageSink);
-
- std::wstring name() override;
- std::wstring description() override;
-
- void handleRequest(const std::vector<std::wstring> &arguments) override;
-
-private:
-
- MessageSink m_messageSink;
-};
-
-}
diff --git a/wfpctl/src/extras/cli/commands/list/providercontexts.cpp b/wfpctl/src/extras/cli/commands/list/providercontexts.cpp
deleted file mode 100644
index 6612ce03dc..0000000000
--- a/wfpctl/src/extras/cli/commands/list/providercontexts.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-#include "stdafx.h"
-#include "providercontexts.h"
-#include "cli/objectproperties.h"
-#include "cli/filterengineprovider.h"
-#include "cli/propertydecorator.h"
-#include "libwfp/objectenumerator.h"
-
-namespace commands::list
-{
-
-ProviderContexts::ProviderContexts(MessageSink messageSink)
- : m_messageSink(messageSink)
-{
-}
-
-std::wstring ProviderContexts::name()
-{
- return L"providercontexts";
-
-}
-
-std::wstring ProviderContexts::description()
-{
- return L"Provides a listing of all provider contexts in the system.";
-}
-
-void ProviderContexts::handleRequest(const std::vector<std::wstring> &arguments)
-{
- if (false == arguments.empty())
- {
- throw std::runtime_error("Unsupported argument(s). Cannot complete request.");
- }
-
- PrettyPrintOptions options;
-
- options.indent = 2;
- options.useSeparator = true;
-
- PropertyDecorator decorator(FilterEngineProvider::Instance().get());
-
- wfp::ObjectEnumerator::ProviderContexts(*FilterEngineProvider::Instance().get(), [&](const FWPM_PROVIDER_CONTEXT0 &context)
- {
- m_messageSink(L"Provider context");
-
- PrettyPrintProperties(m_messageSink, options, ProviderContextProperties(context, &decorator));
-
- return true;
- });
-}
-
-}
diff --git a/wfpctl/src/extras/cli/commands/list/providercontexts.h b/wfpctl/src/extras/cli/commands/list/providercontexts.h
deleted file mode 100644
index b87886eac7..0000000000
--- a/wfpctl/src/extras/cli/commands/list/providercontexts.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#pragma once
-
-#include "cli/commands/icommand.h"
-#include "cli/util.h"
-
-namespace commands::list
-{
-
-class ProviderContexts : public ICommand
-{
-public:
-
- ProviderContexts(MessageSink messageSink);
-
- std::wstring name() override;
- std::wstring description() override;
-
- void handleRequest(const std::vector<std::wstring> &arguments) override;
-
-private:
-
- MessageSink m_messageSink;
-};
-
-}
diff --git a/wfpctl/src/extras/cli/commands/list/providers.cpp b/wfpctl/src/extras/cli/commands/list/providers.cpp
deleted file mode 100644
index a06318d74b..0000000000
--- a/wfpctl/src/extras/cli/commands/list/providers.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-#include "stdafx.h"
-#include "providers.h"
-#include "cli/objectproperties.h"
-#include "cli/filterengineprovider.h"
-#include "libwfp/objectenumerator.h"
-
-namespace commands::list
-{
-
-Providers::Providers(MessageSink messageSink)
- : m_messageSink(messageSink)
-{
-}
-
-std::wstring Providers::name()
-{
- return L"providers";
-
-}
-
-std::wstring Providers::description()
-{
- return L"Provides a listing of all providers in the system.";
-}
-
-void Providers::handleRequest(const std::vector<std::wstring> &arguments)
-{
- if (false == arguments.empty())
- {
- throw std::runtime_error("Unsupported argument(s). Cannot complete request.");
- }
-
- PrettyPrintOptions options;
-
- options.indent = 2;
- options.useSeparator = true;
-
- wfp::ObjectEnumerator::Providers(*FilterEngineProvider::Instance().get(), [&](const FWPM_PROVIDER0 &provider)
- {
- m_messageSink(L"Provider");
-
- PrettyPrintProperties(m_messageSink, options, ProviderProperties(provider));
-
- return true;
- });
-}
-
-}
diff --git a/wfpctl/src/extras/cli/commands/list/providers.h b/wfpctl/src/extras/cli/commands/list/providers.h
deleted file mode 100644
index 2a09a88b67..0000000000
--- a/wfpctl/src/extras/cli/commands/list/providers.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#pragma once
-
-#include "cli/commands/icommand.h"
-#include "cli/util.h"
-
-namespace commands::list
-{
-
-class Providers : public ICommand
-{
-public:
-
- Providers(MessageSink messageSink);
-
- std::wstring name() override;
- std::wstring description() override;
-
- void handleRequest(const std::vector<std::wstring> &arguments) override;
-
-private:
-
- MessageSink m_messageSink;
-};
-
-}
diff --git a/wfpctl/src/extras/cli/commands/list/sessions.cpp b/wfpctl/src/extras/cli/commands/list/sessions.cpp
deleted file mode 100644
index 27000c903d..0000000000
--- a/wfpctl/src/extras/cli/commands/list/sessions.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-#include "stdafx.h"
-#include "sessions.h"
-#include "cli/objectproperties.h"
-#include "cli/filterengineprovider.h"
-#include "libwfp/objectenumerator.h"
-
-namespace commands::list
-{
-
-Sessions::Sessions(MessageSink messageSink)
- : m_messageSink(messageSink)
-{
-}
-
-std::wstring Sessions::name()
-{
- return L"sessions";
-
-}
-
-std::wstring Sessions::description()
-{
- return L"Provides a listing of all active sessions in the system.";
-}
-
-void Sessions::handleRequest(const std::vector<std::wstring> &arguments)
-{
- if (false == arguments.empty())
- {
- throw std::runtime_error("Unsupported argument(s). Cannot complete request.");
- }
-
- PrettyPrintOptions options;
-
- options.indent = 2;
- options.useSeparator = true;
-
- wfp::ObjectEnumerator::Sessions(*FilterEngineProvider::Instance().get(), [&](const FWPM_SESSION0 &session)
- {
- m_messageSink(L"Session");
-
- PrettyPrintProperties(m_messageSink, options, SessionProperties(session));
-
- return true;
- });
-}
-
-}
diff --git a/wfpctl/src/extras/cli/commands/list/sessions.h b/wfpctl/src/extras/cli/commands/list/sessions.h
deleted file mode 100644
index b9d8f04ea2..0000000000
--- a/wfpctl/src/extras/cli/commands/list/sessions.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#pragma once
-
-#include "cli/commands/icommand.h"
-#include "cli/util.h"
-
-namespace commands::list
-{
-
-class Sessions : public ICommand
-{
-public:
-
- Sessions(MessageSink messageSink);
-
- std::wstring name() override;
- std::wstring description() override;
-
- void handleRequest(const std::vector<std::wstring> &arguments) override;
-
-private:
-
- MessageSink m_messageSink;
-};
-
-}
diff --git a/wfpctl/src/extras/cli/commands/list/sublayers.cpp b/wfpctl/src/extras/cli/commands/list/sublayers.cpp
deleted file mode 100644
index 0c8a5f2f58..0000000000
--- a/wfpctl/src/extras/cli/commands/list/sublayers.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-#include "stdafx.h"
-#include "sublayers.h"
-#include "cli/objectproperties.h"
-#include "cli/filterengineprovider.h"
-#include "cli/propertydecorator.h"
-#include "libwfp/objectenumerator.h"
-
-namespace commands::list
-{
-
-Sublayers::Sublayers(MessageSink messageSink)
- : m_messageSink(messageSink)
-{
-}
-
-std::wstring Sublayers::name()
-{
- return L"sublayers";
-
-}
-
-std::wstring Sublayers::description()
-{
- return L"Provides a listing of all sublayers in the system.";
-}
-
-void Sublayers::handleRequest(const std::vector<std::wstring> &arguments)
-{
- if (false == arguments.empty())
- {
- throw std::runtime_error("Unsupported argument(s). Cannot complete request.");
- }
-
- PrettyPrintOptions options;
-
- options.indent = 2;
- options.useSeparator = true;
-
- PropertyDecorator decorator(FilterEngineProvider::Instance().get());
-
- wfp::ObjectEnumerator::Sublayers(*FilterEngineProvider::Instance().get(), [&](const FWPM_SUBLAYER0 &sublayer)
- {
- m_messageSink(L"Sublayer");
-
- PrettyPrintProperties(m_messageSink, options, SublayerProperties(sublayer, &decorator));
-
- return true;
- });
-}
-
-}
diff --git a/wfpctl/src/extras/cli/commands/list/sublayers.h b/wfpctl/src/extras/cli/commands/list/sublayers.h
deleted file mode 100644
index e9b34bbd52..0000000000
--- a/wfpctl/src/extras/cli/commands/list/sublayers.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#pragma once
-
-#include "cli/commands/icommand.h"
-#include "cli/util.h"
-
-namespace commands::list
-{
-
-class Sublayers : public ICommand
-{
-public:
-
- Sublayers(MessageSink messageSink);
-
- std::wstring name() override;
- std::wstring description() override;
-
- void handleRequest(const std::vector<std::wstring> &arguments) override;
-
-private:
-
- MessageSink m_messageSink;
-};
-
-}
diff --git a/wfpctl/src/extras/cli/commands/monitor/m_events.cpp b/wfpctl/src/extras/cli/commands/monitor/m_events.cpp
deleted file mode 100644
index 294ae38e9c..0000000000
--- a/wfpctl/src/extras/cli/commands/monitor/m_events.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-#include "stdafx.h"
-#include "m_events.h"
-#include "cli/objectproperties.h"
-#include "cli/propertydecorator.h"
-#include "cli/filterengineprovider.h"
-#include "libwfp/objectmonitor.h"
-#include <conio.h>
-
-namespace commands::monitor
-{
-
-Events::Events(MessageSink messageSink)
- : m_messageSink(messageSink)
-{
-}
-
-std::wstring Events::name()
-{
- return L"events";
-
-}
-
-std::wstring Events::description()
-{
- return L"Provides monitoring of drop/allow events.";
-}
-
-void Events::handleRequest(const std::vector<std::wstring> &arguments)
-{
- if (false == arguments.empty())
- {
- throw std::runtime_error("Unsupported argument(s). Cannot complete request.");
- }
-
- wfp::ObjectMonitor objectMonitor(FilterEngineProvider::Instance().get());
-
- objectMonitor.monitorEvents(std::bind(&Events::eventCallback, this, std::placeholders::_1));
-
- m_messageSink(L"Successfully enabled monitor. Press any key to abort monitoring.");
-
- //
- // This assumes we're in a console environment, but the alternative is to have
- // the command (this class) communicate to the outside world that we're in
- // a monitoring state.
- //
- // Hence, this is sufficient for now.
- //
-
- _getwch();
-
- objectMonitor.monitorEventsStop();
-}
-
-void Events::eventCallback(const FWPM_NET_EVENT1 &event)
-{
- m_messageSink(L"Event");
-
- PrettyPrintOptions options;
-
- options.indent = 2;
- options.useSeparator = true;
-
- PropertyDecorator decorator(FilterEngineProvider::Instance().get());
-
- PrettyPrintProperties(m_messageSink, options, EventProperties(event, &decorator));
-}
-
-}
diff --git a/wfpctl/src/extras/cli/commands/monitor/m_events.h b/wfpctl/src/extras/cli/commands/monitor/m_events.h
deleted file mode 100644
index e8724129e8..0000000000
--- a/wfpctl/src/extras/cli/commands/monitor/m_events.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#pragma once
-
-#include "cli/commands/icommand.h"
-#include "cli/util.h"
-#include <memory>
-
-namespace commands::monitor
-{
-
-class Events : public ICommand
-{
-public:
-
- Events(MessageSink messageSink);
-
- std::wstring name() override;
- std::wstring description() override;
-
- void handleRequest(const std::vector<std::wstring> &arguments) override;
-
-private:
-
- MessageSink m_messageSink;
-
- void eventCallback(const FWPM_NET_EVENT1 &event);
-};
-
-}
diff --git a/wfpctl/src/extras/cli/commands/wfpctl/deinit.cpp b/wfpctl/src/extras/cli/commands/wfpctl/deinit.cpp
deleted file mode 100644
index fc5f5e0b2e..0000000000
--- a/wfpctl/src/extras/cli/commands/wfpctl/deinit.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-#include "stdafx.h"
-#include "deinit.h"
-#include "wfpctl/wfpctl.h"
-
-namespace commands::wfpctl
-{
-
-Deinit::Deinit(MessageSink messageSink)
- : m_messageSink(messageSink)
-{
-}
-
-std::wstring Deinit::name()
-{
- return L"deinit";
-}
-
-std::wstring Deinit::description()
-{
- return L"Deinitialize wfpctl; Destroy session and all associated objects";
-}
-
-void Deinit::handleRequest(const std::vector<std::wstring> &arguments)
-{
- if (false == arguments.empty())
- {
- throw std::runtime_error("Invalid argument(s). Cannot complete request.");
- }
-
- m_messageSink((Wfpctl_Deinitialize()
- ? L"Deinitialization completed successfully."
- : L"Deinitialization failed. See above for details, if any."));
-}
-
-}
diff --git a/wfpctl/src/extras/cli/commands/wfpctl/deinit.h b/wfpctl/src/extras/cli/commands/wfpctl/deinit.h
deleted file mode 100644
index f445566f02..0000000000
--- a/wfpctl/src/extras/cli/commands/wfpctl/deinit.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#pragma once
-
-#include "cli/commands/icommand.h"
-#include "cli/util.h"
-
-namespace commands::wfpctl
-{
-
-class Deinit : public ICommand
-{
-public:
-
- Deinit(MessageSink messageSink);
-
- std::wstring name() override;
- std::wstring description() override;
-
- void handleRequest(const std::vector<std::wstring> &arguments) override;
-
-private:
-
- MessageSink m_messageSink;
-};
-
-}
diff --git a/wfpctl/src/extras/cli/commands/wfpctl/init.cpp b/wfpctl/src/extras/cli/commands/wfpctl/init.cpp
deleted file mode 100644
index eb569f55e7..0000000000
--- a/wfpctl/src/extras/cli/commands/wfpctl/init.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-#include "stdafx.h"
-#include "init.h"
-#include "libcommon/string.h"
-
-namespace commands::wfpctl
-{
-
-Init::Init(MessageSink messageSink)
- : m_messageSink(messageSink)
-{
-}
-
-std::wstring Init::name()
-{
- return L"init";
-}
-
-std::wstring Init::description()
-{
- return L"Initialize wfpctl; Create session and fundamental objects";
-}
-
-void Init::handleRequest(const std::vector<std::wstring> &arguments)
-{
- uint32_t timeout = 0;
-
- if (false == arguments.empty())
- {
- auto keyvalue = common::string::SplitKeyValuePairs(arguments);
-
- if (keyvalue.empty() || 0 != keyvalue.begin()->first.compare(L"timeout"))
- {
- throw std::runtime_error("Invalid argument. Cannot complete request.");
- }
-
- timeout = wcstoul(keyvalue.begin()->second.c_str(), nullptr, 10);
- }
-
- auto success = Wfpctl_Initialize(timeout, &Init::ErrorForwarder, this);
-
- m_messageSink((success
- ? L"Initialization completed successfully."
- : L"Initialization failed. See above for details, if any."));
-}
-
-//static
-void WFPCTL_API Init::ErrorForwarder(const char *errorMessage, void *context)
-{
- auto thiz = reinterpret_cast<Init *>(context);
-
- thiz->m_messageSink(common::string::ToWide(errorMessage));
-}
-
-}
diff --git a/wfpctl/src/extras/cli/commands/wfpctl/init.h b/wfpctl/src/extras/cli/commands/wfpctl/init.h
deleted file mode 100644
index 96686a2680..0000000000
--- a/wfpctl/src/extras/cli/commands/wfpctl/init.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#pragma once
-
-#include "cli/commands/icommand.h"
-#include "cli/util.h"
-#include "wfpctl/wfpctl.h"
-
-namespace commands::wfpctl
-{
-
-class Init : public ICommand
-{
-public:
-
- Init(MessageSink messageSink);
-
- std::wstring name() override;
- std::wstring description() override;
-
- void handleRequest(const std::vector<std::wstring> &arguments) override;
-
-private:
-
- MessageSink m_messageSink;
-
- static void WFPCTL_API ErrorForwarder(const char *errorMessage, void *context);
-};
-
-}
diff --git a/wfpctl/src/extras/cli/commands/wfpctl/policy.cpp b/wfpctl/src/extras/cli/commands/wfpctl/policy.cpp
deleted file mode 100644
index 3d4ce2aaf6..0000000000
--- a/wfpctl/src/extras/cli/commands/wfpctl/policy.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-#include "stdafx.h"
-#include "policy.h"
-#include "libcommon/string.h"
-#include "wfpctl/wfpctl.h"
-#include <functional>
-
-namespace commands::wfpctl
-{
-
-namespace detail
-{
-
-WfpctlSettings CreateSettings(const std::wstring &dhcp, const std::wstring &lan)
-{
- WfpctlSettings s;
-
- s.permitDhcp = (0 == _wcsicmp(dhcp.c_str(), L"yes"));
- s.permitLan = (0 == _wcsicmp(lan.c_str(), L"yes"));
-
- return s;
-}
-
-WfpctlProtocol TranslateProtocol(const std::wstring &protocol)
-{
- return (0 == _wcsicmp(protocol.c_str(), L"tcp") ? WfpctlProtocol::Tcp : WfpctlProtocol::Udp);
-}
-
-WfpctlRelay CreateRelay(const wchar_t *ip, const std::wstring &port, const std::wstring &protocol)
-{
- WfpctlRelay r;
-
- r.ip = ip;
- r.port = common::string::LexicalCast<uint16_t>(port);
- r.protocol = TranslateProtocol(protocol);
-
- return r;
-}
-
-} // namespace detail
-
-Policy::Policy(MessageSink messageSink)
- : m_messageSink(messageSink)
-{
- m_dispatcher.addSubcommand
- (
- L"connecting",
- std::bind(&Policy::processConnecting, this, std::placeholders::_1)
- );
-
- m_dispatcher.addSubcommand
- (
- L"connected",
- std::bind(&Policy::processConnected, this, std::placeholders::_1)
- );
-
- m_dispatcher.addSubcommand
- (
- L"netblocked",
- std::bind(&Policy::processNetBlocked, this)
- );
-
- m_dispatcher.addSubcommand
- (
- L"reset",
- std::bind(&Policy::processReset, this)
- );
-}
-
-std::wstring Policy::name()
-{
- return L"policy";
-}
-
-std::wstring Policy::description()
-{
- return L"Activate and reset policies.";
-}
-
-void Policy::handleRequest(const std::vector<std::wstring> &arguments)
-{
- if (arguments.empty())
- {
- throw std::runtime_error("Missing subcommand. Cannot complete request.");
- }
-
- auto subcommand = arguments[0];
-
- auto actualArguments(arguments);
- actualArguments.erase(actualArguments.begin());
-
- m_dispatcher.dispatch(subcommand, actualArguments);
-}
-
-void Policy::processConnecting(const KeyValuePairs &arguments)
-{
- auto settings = detail::CreateSettings
- (
- GetArgumentValue(arguments, L"dhcp"),
- GetArgumentValue(arguments, L"lan")
- );
-
- auto r = GetArgumentValue(arguments, L"relay");
-
- auto relay = detail::CreateRelay
- (
- r.c_str(),
- GetArgumentValue(arguments, L"port"),
- GetArgumentValue(arguments, L"protocol")
- );
-
- auto success = Wfpctl_ApplyPolicyConnecting
- (
- settings,
- relay
- );
-
- m_messageSink((success
- ? L"Successfully applied policy."
- : L"Failed to apply policy."));
-}
-
-void Policy::processConnected(const KeyValuePairs &arguments)
-{
- auto settings = detail::CreateSettings
- (
- GetArgumentValue(arguments, L"dhcp"),
- GetArgumentValue(arguments, L"lan")
- );
-
- auto r = GetArgumentValue(arguments, L"relay");
-
- auto relay = detail::CreateRelay
- (
- r.c_str(),
- GetArgumentValue(arguments, L"port"),
- GetArgumentValue(arguments, L"protocol")
- );
-
- auto success = Wfpctl_ApplyPolicyConnected
- (
- settings,
- relay,
- GetArgumentValue(arguments, L"tunnel").c_str(),
- GetArgumentValue(arguments, L"dns").c_str()
- );
-
- m_messageSink((success
- ? L"Successfully applied policy."
- : L"Failed to apply policy."));
-}
-
-void Policy::processNetBlocked()
-{
- auto success = Wfpctl_ApplyPolicyNetBlocked();
-
- m_messageSink((success
- ? L"Successfully applied policy."
- : L"Failed to apply policy."));
-}
-
-void Policy::processReset()
-{
- auto success = Wfpctl_Reset();
-
- m_messageSink((success
- ? L"Successfully reset policy."
- : L"Failed to reset policy."));
-}
-
-}
diff --git a/wfpctl/src/extras/cli/commands/wfpctl/policy.h b/wfpctl/src/extras/cli/commands/wfpctl/policy.h
deleted file mode 100644
index 524640d3e6..0000000000
--- a/wfpctl/src/extras/cli/commands/wfpctl/policy.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#pragma once
-
-#include "cli/commands/icommand.h"
-#include "cli/util.h"
-#include "cli/subcommanddispatcher.h"
-#include "libcommon/string.h"
-
-namespace commands::wfpctl
-{
-
-class Policy : public ICommand
-{
-public:
-
- Policy(MessageSink messageSink);
-
- std::wstring name() override;
- std::wstring description() override;
-
- void handleRequest(const std::vector<std::wstring> &arguments) override;
-
-private:
-
- MessageSink m_messageSink;
- SubcommandDispatcher m_dispatcher;
-
- using KeyValuePairs = common::string::KeyValuePairs;
-
- void processConnecting(const KeyValuePairs &arguments);
- void processConnected(const KeyValuePairs &arguments);
- void processNetBlocked();
- void processReset();
-};
-
-}