]> granicus.if.org Git - icinga2/commitdiff
Implemented demo component.
authorGunnar Beutner <gunnar.beutner@netways.de>
Mon, 23 Apr 2012 11:45:41 +0000 (13:45 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Mon, 23 Apr 2012 11:45:41 +0000 (13:45 +0200)
19 files changed:
components/Makefile.am
components/demo/Makefile.am [new file with mode: 0644]
components/demo/demo.vcxproj [new file with mode: 0644]
components/demo/democomponent.cpp [new file with mode: 0644]
components/demo/democomponent.h [new file with mode: 0644]
components/demo/i2-demo.h [new file with mode: 0644]
configure.ac
icinga-app/icinga.conf
icinga.sln
icinga/authenticationcomponent.cpp
icinga/endpoint.h
icinga/endpointmanager.cpp
icinga/icingaapplication.cpp
icinga/icingaapplication.h
icinga/jsonrpcendpoint.cpp
icinga/jsonrpcendpoint.h
icinga/subscriptioncomponent.cpp
icinga/virtualendpoint.cpp
icinga/virtualendpoint.h

index e32fb4b854d5c34cc2639b495baa40ed8bbe70af..da8b0020f36f59e188d7df2d5624fb5dfa93f961 100644 (file)
@@ -2,4 +2,5 @@
 ## Created by Anjuta
 
 SUBDIRS = configfile \
-       configrpc
+       configrpc \
+       demo
diff --git a/components/demo/Makefile.am b/components/demo/Makefile.am
new file mode 100644 (file)
index 0000000..d49b52c
--- /dev/null
@@ -0,0 +1,20 @@
+## Process this file with automake to produce Makefile.in
+
+pkglib_LTLIBRARIES =  \
+       demo.la
+
+demo_la_SOURCES =  \
+       democomponent.cpp \
+       democomponent.h \
+       i2-demo.h
+
+demo_la_CXXFLAGS = -I${top_srcdir}/base \
+       -I${top_srcdir}/jsonrpc \
+       -I${top_srcdir}/cJSON \
+       -I${top_srcdir}/icinga
+
+demo_la_LDFLAGS = -module -version-info 0:0:0 -no-undefined -pthread
+demo_la_LIBADD = ${top_builddir}/base/libbase.la \
+       ${top_builddir}/jsonrpc/libjsonrpc.la \
+       ${top_builddir}/cJSON/libcJSON.la \
+       ${top_builddir}/icinga/libicinga.la
diff --git a/components/demo/demo.vcxproj b/components/demo/demo.vcxproj
new file mode 100644 (file)
index 0000000..5a96b64
--- /dev/null
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{2E6C1133-730F-4875-A72C-B455B1DD4C5C}</ProjectGuid>
+    <Keyword>Win32Proj</Keyword>
+    <RootNamespace>demo</RootNamespace>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <LinkIncremental>true</LinkIncremental>
+    <IncludePath>$(SolutionDir)\base;$(SolutionDir)\jsonrpc;$(SolutionDir)\icinga;$(IncludePath)</IncludePath>
+    <LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <LinkIncremental>false</LinkIncremental>
+    <IncludePath>$(SolutionDir)\base;$(SolutionDir)\jsonrpc;$(SolutionDir)\icinga;$(IncludePath)</IncludePath>
+    <LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;DEMO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalDependencies>base.lib;jsonrpc.lib;icinga.lib;cJSON.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;DEMO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <AdditionalDependencies>base.lib;jsonrpc.lib;icinga.lib;cJSON.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <ClInclude Include="democomponent.h" />
+    <ClInclude Include="i2-demo.h" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="democomponent.cpp" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>
\ No newline at end of file
diff --git a/components/demo/democomponent.cpp b/components/demo/democomponent.cpp
new file mode 100644 (file)
index 0000000..7d326c6
--- /dev/null
@@ -0,0 +1,69 @@
+#include "i2-demo.h"
+
+using namespace icinga;
+
+IcingaApplication::Ptr DemoComponent::GetIcingaApplication(void)
+{
+       return static_pointer_cast<IcingaApplication>(GetApplication());
+}
+
+string DemoComponent::GetName(void) const
+{
+       return "democomponent";
+}
+
+void DemoComponent::Start(void)
+{
+       m_DemoEndpoint = make_shared<VirtualEndpoint>();
+       m_DemoEndpoint->RegisterMethodSink("demo::HelloWorld");
+       m_DemoEndpoint->RegisterMethodSource("demo::HelloWorld");
+
+       EndpointManager::Ptr endpointManager = GetIcingaApplication()->GetEndpointManager();
+       endpointManager->RegisterEndpoint(m_DemoEndpoint);
+
+       endpointManager->OnNewEndpoint += bind_weak(&DemoComponent::NewEndpointHandler, shared_from_this());
+       endpointManager->ForeachEndpoint(bind(&DemoComponent::NewEndpointHandler, this, _1));
+
+       m_DemoTimer = make_shared<Timer>();
+       m_DemoTimer->SetInterval(1);
+       m_DemoTimer->OnTimerExpired += bind_weak(&DemoComponent::DemoTimerHandler, shared_from_this());
+       m_DemoTimer->Start();
+}
+
+void DemoComponent::Stop(void)
+{
+       EndpointManager::Ptr endpointManager = GetIcingaApplication()->GetEndpointManager();
+       endpointManager->UnregisterEndpoint(m_DemoEndpoint);
+}
+
+int AuthenticationComponent::NewEndpointHandler(const NewEndpointEventArgs& neea)
+{
+       neea.Endpoint->AddAllowedMethodSinkPrefix("demo");
+       neea.Endpoint->AddAllowedMethodSourcePrefix("demo");
+
+       return 0;
+}
+
+int DemoComponent::DemoTimerHandler(const TimerEventArgs& tea)
+{
+       cout << "Sending multicast 'hello world' message." << endl;
+
+       JsonRpcRequest request;
+       request.SetMethod("test");
+
+       EndpointManager::Ptr endpointManager = GetIcingaApplication()->GetEndpointManager();
+
+       for (int i = 0; i < 5; i++)
+               endpointManager->SendMulticastRequest(m_DemoEndpoint, request);
+
+       return 0;
+}
+
+int DemoComponent::HelloWorldRequestHAndler(const NewRequestEventArgs& nrea)
+{
+       cout << "Got Hello World from " << nrea.Sender->GetAddress();
+
+       return 0;
+}
+
+EXPORT_COMPONENT(DemoComponent);
diff --git a/components/demo/democomponent.h b/components/demo/democomponent.h
new file mode 100644 (file)
index 0000000..3faaa6a
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef DEMOCOMPONENT_H
+#define DEMOCOMPONENT_H
+
+namespace icinga
+{
+
+class DemoComponent : public Component
+{
+private:
+       Timer::Ptr m_DemoTimer;
+       VirtualEndpoint::Ptr m_DemoEndpoint;
+
+       IcingaApplication::Ptr GetIcingaApplication(void);
+
+       int DemoTimerHandler(const TimerEventArgs& tea);
+       int NewEndpointHandler(const NewEndpointEventArgs& neea);
+       int HelloWorldRequestHAndler(const NewRequestEventArgs& nrea);
+
+public:
+       virtual string GetName(void) const;
+       virtual void Start(void);
+       virtual void Stop(void);
+};
+
+}
+
+#endif /* DEMOCOMPONENT_H */
diff --git a/components/demo/i2-demo.h b/components/demo/i2-demo.h
new file mode 100644 (file)
index 0000000..f427017
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef I2DEMO_H
+#define I2DEMO_H
+
+#include <i2-base.h>
+#include <i2-jsonrpc.h>
+#include <i2-icinga.h>
+
+#include "democomponent.h"
+
+#endif /* I2DEMO_H */
index 70e549fa85a8186628610dcaae66a53aacf33023..24849cde68f63ae4f463e0875a4254d3580fd4d3 100644 (file)
@@ -47,6 +47,7 @@ cJSON/Makefile
 components/Makefile
 components/configfile/Makefile
 components/configrpc/Makefile
+components/demo/Makefile
 icinga/Makefile
 icinga-app/Makefile
 jsonrpc/Makefile
index 050bf4df6cb849757440e6a40cb066040730221d..440c71715db41f5e7a833877034152548f918b5e 100644 (file)
@@ -1,8 +1,8 @@
 {
        "component": {
-               "configrpc": { "replicate": "0", "configSource": "1" }
+               "configrpc": { "replicate": "0", "configSource": "1" },
+               "demo": { "replicate": "0" }
        },
-
        "rpclistener": {
                "kekslistener": { "replicate": "0", "port": "7777" }
        },
index b165bd7f1a0f39d81b781bca8ff81433d71fe95c..b8ac15f900bc2703f3e98c0710e76c6813d40fec 100644 (file)
@@ -32,6 +32,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "configrpc", "components\con
                {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} = {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}
        EndProjectSection
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "demo", "components\demo\demo.vcxproj", "{2E6C1133-730F-4875-A72C-B455B1DD4C5C}"
+       ProjectSection(ProjectDependencies) = postProject
+               {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} = {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}
+       EndProjectSection
+EndProject
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
                Debug|Win32 = Debug|Win32
@@ -66,6 +71,10 @@ Global
                {697C6D7E-3109-484C-A7AF-384D28711610}.Debug|Win32.Build.0 = Debug|Win32
                {697C6D7E-3109-484C-A7AF-384D28711610}.Release|Win32.ActiveCfg = Release|Win32
                {697C6D7E-3109-484C-A7AF-384D28711610}.Release|Win32.Build.0 = Release|Win32
+               {2E6C1133-730F-4875-A72C-B455B1DD4C5C}.Debug|Win32.ActiveCfg = Debug|Win32
+               {2E6C1133-730F-4875-A72C-B455B1DD4C5C}.Debug|Win32.Build.0 = Debug|Win32
+               {2E6C1133-730F-4875-A72C-B455B1DD4C5C}.Release|Win32.ActiveCfg = Release|Win32
+               {2E6C1133-730F-4875-A72C-B455B1DD4C5C}.Release|Win32.Build.0 = Release|Win32
        EndGlobalSection
        GlobalSection(SolutionProperties) = preSolution
                HideSolutionNode = FALSE
index 78b1c83f1c460af81dd9e01ae66a4fd7ba224f39..3adff23cf81b769774435bcef5c99f541e67fd66 100644 (file)
@@ -38,6 +38,9 @@ int AuthenticationComponent::NewEndpointHandler(const NewEndpointEventArgs& neea
        if (neea.Endpoint->IsLocal() || neea.Endpoint->HasIdentity())
                return 0;
 
+       neea.Endpoint->AddAllowedMethodSinkPrefix("auth::");
+       neea.Endpoint->AddAllowedMethodSourcePrefix("auth::");
+
        JsonRpcRequest request;
        request.SetMethod("message::SetIdentity");
 
index 96591a2e2603736257a9ba5aa10419f2e4396c65..317cbd956e6aa00203e8ca60d1d7248b08310711 100644 (file)
@@ -24,6 +24,8 @@ public:
        typedef shared_ptr<Endpoint> Ptr;
        typedef weak_ptr<Endpoint> WeakPtr;
 
+       virtual string GetAddress(void) const = 0;
+
        string GetIdentity(void) const;
        void SetIdentity(string identity);
        bool HasIdentity(void) const;
@@ -38,6 +40,13 @@ public:
        void RegisterMethodSource(string method);
        void UnregisterMethodSource(string method);
        bool IsMethodSource(string method) const;
+       
+       virtual void AddAllowedMethodSinkPrefix(string method) = 0;
+       virtual void RemoveAllowedMethodSinkPrefix(string method) = 0;
+       virtual bool IsAllowedMethodSink(string method) const = 0;
+       virtual void AddAllowedMethodSourcePrefix(string method) = 0;
+       virtual void RemoveAllowedMethodSourcePrefix(string method) = 0;
+       virtual bool IsAllowedMethodSource(string method) const = 0;
 
        virtual bool IsLocal(void) const = 0;
 
index 3b655b3ae599c6d7adea7b5106ad6252ff6e58e9..1f6172eb2603a582b6a26e31b602754e7fe1e8af 100644 (file)
@@ -101,7 +101,7 @@ void EndpointManager::SendMulticastRequest(Endpoint::Ptr sender, const JsonRpcRe
                if (!fromLocal && !endpoint->IsLocal())
                        continue;
 
-               if (endpoint->IsMethodSink(method))
+               if (endpoint->IsMethodSink(method) && endpoint->IsAllowedMethodSink(method))
                        endpoint->ProcessRequest(sender, request);
        }
 }
index f31349582a972af1f4a5ae5b8b7cb743f26fadca..228da63cb17dd69adfa97502c0911e4176280d1b 100644 (file)
@@ -67,34 +67,11 @@ int IcingaApplication::Main(const vector<string>& args)
 
        ConfigCollection::Ptr collection = GetConfigHive()->GetCollection("rpclistener");
 
-       m_TestEndpoint = make_shared<VirtualEndpoint>();
-       m_EndpointManager->RegisterEndpoint(m_TestEndpoint);
-       m_TestEndpoint->RegisterMethodSink("test");
-       m_TestEndpoint->RegisterMethodSource("test");
-
-       m_TestTimer = make_shared<Timer>();
-       m_TestTimer->SetInterval(1);
-       m_TestTimer->OnTimerExpired += bind_weak(&IcingaApplication::TestTimerHandler, shared_from_this());
-       m_TestTimer->Start();
-
        RunEventLoop();
 
        return EXIT_SUCCESS;
 }
 
-int IcingaApplication::TestTimerHandler(const TimerEventArgs& tea)
-{
-       cout << "Problem?" << endl;
-
-       JsonRpcRequest request;
-       request.SetMethod("test");
-
-       for (int i = 0; i < 5; i++)
-               m_EndpointManager->SendMulticastRequest(m_TestEndpoint, request);
-
-       return 0;
-}
-
 void IcingaApplication::PrintUsage(const string& programPath)
 {
        cout << "Syntax: " << programPath << " <config-file>" << endl;
index 6d86e55d40ac2eaaffa6a13bd755598f5ef369e1..3205d68972b25d52e64821bf6454cde2874cfdd2 100644 (file)
@@ -8,8 +8,6 @@ class I2_ICINGA_API IcingaApplication : public Application
 {
 private:
        EndpointManager::Ptr m_EndpointManager;
-       Timer::Ptr m_TestTimer;
-       VirtualEndpoint::Ptr m_TestEndpoint;
 
        int NewComponentHandler(const EventArgs& ea);
        int DeletedComponentHandler(const EventArgs& ea);
index c6019d920de1724331858c7d47ecf9870021ed27..88597372ae47af2770f2fa10acc53d12c2ef7ea2 100644 (file)
@@ -2,13 +2,57 @@
 
 using namespace icinga;
 
+void JsonRpcEndpoint::SetAddress(string address)
+{
+       m_Address = address;
+}
+
+string JsonRpcEndpoint::GetAddress(void) const
+{
+       return m_Address;
+}
+
 JsonRpcClient::Ptr JsonRpcEndpoint::GetClient(void)
 {
        return m_Client;
 }
 
+void JsonRpcEndpoint::AddAllowedMethodSinkPrefix(string method)
+{
+       m_AllowedMethodSinkPrefixes.insert(method);
+}
+
+void JsonRpcEndpoint::RemoveAllowedMethodSinkPrefix(string method)
+{
+       m_AllowedMethodSinkPrefixes.erase(method);
+}
+
+bool JsonRpcEndpoint::IsAllowedMethodSink(string method) const
+{
+       return (m_AllowedMethodSinkPrefixes.find(method) != m_AllowedMethodSinkPrefixes.end());
+}
+
+void JsonRpcEndpoint::AddAllowedMethodSourcePrefix(string method)
+{
+       m_AllowedMethodSourcePrefixes.insert(method);
+}
+
+void JsonRpcEndpoint::RemoveAllowedMethodSourcePrefix(string method)
+{
+       m_AllowedMethodSourcePrefixes.erase(method);
+}
+
+bool JsonRpcEndpoint::IsAllowedMethodSource(string method) const
+{
+       return (m_AllowedMethodSourcePrefixes.find(method) != m_AllowedMethodSourcePrefixes.end());
+}
+
 void JsonRpcEndpoint::Connect(string host, unsigned short port)
 {
+       char portStr[20];
+       sprintf(portStr, "%d", port);
+       SetAddress("jsonrpc-tcp://" + host + ":" + portStr);
+
        JsonRpcClient::Ptr client = make_shared<JsonRpcClient>();
        client->MakeSocket();
        client->Connect(host, port);
@@ -62,6 +106,9 @@ int JsonRpcEndpoint::NewMessageHandler(const NewMessageEventArgs& nmea)
 
        string method;
        if (message.GetPropertyString("method", &method)) {
+               if (!IsAllowedMethodSource(method))
+                       return 0;
+
                JsonRpcRequest request = message;
 
                string id;
index 306ca932943d0cd4de70c4a6f37173a453736087..7d6b0a1b88f39df3ec958ca6bb794ac43f349988 100644 (file)
@@ -7,9 +7,12 @@ namespace icinga
 class I2_ICINGA_API JsonRpcEndpoint : public Endpoint
 {
 private:
+       string m_Address;
        JsonRpcClient::Ptr m_Client;
        map<string, Endpoint::Ptr> m_PendingCalls;
        Timer::Ptr m_ReconnectTimer;
+       set<string> m_AllowedMethodSinkPrefixes;
+       set<string> m_AllowedMethodSourcePrefixes;
 
        bool IsConnected(void) const;
        
@@ -27,6 +30,16 @@ public:
        JsonRpcClient::Ptr GetClient(void);
        void SetClient(JsonRpcClient::Ptr client);
 
+       void SetAddress(string address);
+       virtual string GetAddress(void) const;
+
+       virtual void AddAllowedMethodSinkPrefix(string method);
+       virtual void RemoveAllowedMethodSinkPrefix(string method);
+       virtual bool IsAllowedMethodSink(string method) const;
+       virtual void AddAllowedMethodSourcePrefix(string method);
+       virtual void RemoveAllowedMethodSourcePrefix(string method);
+       virtual bool IsAllowedMethodSource(string method) const;
+
        virtual bool IsLocal(void) const;
 
        virtual void ProcessRequest(Endpoint::Ptr sender, const JsonRpcRequest& message);
index 78e881334e44894d6104c257fc526dcb4abfac84..6af4bffbdbdc7a68cf1e3593823deaacf2fd0de9 100644 (file)
@@ -75,6 +75,9 @@ int SubscriptionComponent::NewEndpointHandler(const NewEndpointEventArgs& neea)
        EndpointManager::Ptr mgr = GetIcingaApplication()->GetEndpointManager();
        mgr->ForeachEndpoint(bind(&SubscriptionComponent::SyncSubscriptions, this, neea.Endpoint, _1));
 
+       neea.Endpoint->AddAllowedMethodSinkPrefix("message::");
+       neea.Endpoint->AddAllowedMethodSourcePrefix("message::");
+
        return 0;
 }
 
index f1a203d27722bf9191647f9d118f95bb87c24ea7..b22f2420efb63da677ae285f9b9b29239983c06c 100644 (file)
@@ -2,6 +2,13 @@
 
 using namespace icinga;
 
+string VirtualEndpoint::GetAddress(void) const
+{
+       char address[50];
+       sprintf(address, "virtual:%p", this);
+       return address;
+}
+
 bool VirtualEndpoint::IsLocal(void) const
 {
        return true;
@@ -46,3 +53,33 @@ void VirtualEndpoint::ProcessResponse(Endpoint::Ptr sender, const JsonRpcRespons
        // TODO: figure out which request this response belongs to and notify the caller
        throw NotImplementedException();
 }
+
+void VirtualEndpoint::AddAllowedMethodSinkPrefix(string method)
+{
+       /* Nothing to do here. */
+}
+
+void VirtualEndpoint::RemoveAllowedMethodSinkPrefix(string method)
+{
+       /* Nothing to do here. */
+}
+
+void VirtualEndpoint::AddAllowedMethodSourcePrefix(string method)
+{
+       /* Nothing to do here. */
+}
+
+void VirtualEndpoint::RemoveAllowedMethodSourcePrefix(string method)
+{
+       /* Nothing to do here. */
+}
+
+bool VirtualEndpoint::IsAllowedMethodSink(string method) const
+{
+       return true;
+}
+
+bool VirtualEndpoint::IsAllowedMethodSource(string method) const
+{
+       return true;
+}
index ecf4202257a95b97271666b0bd2a3ea866ba0289..e363dd025c9b05b1455a6783fe5841286478285a 100644 (file)
@@ -25,6 +25,15 @@ public:
        void RegisterMethodHandler(string method, function<int (const NewRequestEventArgs&)> callback);
        void UnregisterMethodHandler(string method, function<int (const NewRequestEventArgs&)> callback);
 
+       virtual void AddAllowedMethodSinkPrefix(string method);
+       virtual void RemoveAllowedMethodSinkPrefix(string method);
+       virtual bool IsAllowedMethodSink(string method) const;
+       virtual void AddAllowedMethodSourcePrefix(string method);
+       virtual void RemoveAllowedMethodSourcePrefix(string method);
+       virtual bool IsAllowedMethodSource(string method) const;
+
+       virtual string GetAddress(void) const;
+
        virtual bool IsLocal(void) const;
 
        virtual void ProcessRequest(Endpoint::Ptr sender, const JsonRpcRequest& message);