Exemplo n.º 1
0
        public RemotingServer(FMSImplementation p, string dataDir)
        {
            plugin = p;

            settingsServer = new SettingStore(dataDir);

            AppDomain.CurrentDomain.AssemblyResolve += ResolveEventHandler;
            AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += ResolveEventHandler;

            //Configure .NET Remoting
            if (System.IO.File.Exists(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile))
            {
                RemotingConfiguration.Configure(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile, false);
            }
            if (System.Runtime.Remoting.Channels.ChannelServices.RegisteredChannels.Count() == 0)
            {
                var clientFormatter = new System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider();
                var serverFormatter = new System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider();
                serverFormatter.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
                var props = new System.Collections.Hashtable();
                props["port"] = 8086;
                System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(new System.Runtime.Remoting.Channels.Tcp.TcpChannel(props, clientFormatter, serverFormatter), false);

                System.Runtime.Remoting.Lifetime.LifetimeServices.LeaseTime            = TimeSpan.FromMinutes(3);
                System.Runtime.Remoting.Lifetime.LifetimeServices.SponsorshipTimeout   = TimeSpan.FromMinutes(2);
                System.Runtime.Remoting.Lifetime.LifetimeServices.RenewOnCallTime      = TimeSpan.FromMinutes(1);
                System.Runtime.Remoting.Lifetime.LifetimeServices.LeaseManagerPollTime = TimeSpan.FromSeconds(10);
                System.Runtime.Remoting.RemotingConfiguration.CustomErrorsMode         = System.Runtime.Remoting.CustomErrorsModes.Off;
            }

            var jobDb      = plugin.Backend.JobDatabase();
            var logDb      = plugin.Backend.LogDatabase();
            var inspServer = plugin.Backend.InspectionControl();
            var jobControl = plugin.Backend.JobControl();
            var oldJob     = plugin.Backend.OldJobDecrement();

            singletons = new RemoteSingletons();

            singletons.RemoteSingleton(typeof(IJobDatabase),
                                       "JobDB",
                                       jobDb);
            singletons.RemoteSingleton(typeof(ILogDatabase),
                                       "LogDB",
                                       logDb);
            singletons.RemoteSingleton(typeof(IInspectionControl),
                                       "InspectionControl",
                                       inspServer);
            singletons.RemoteSingleton(typeof(IJobControl),
                                       "JobControl",
                                       jobControl);
            singletons.RemoteSingleton(typeof(IOldJobDecrement),
                                       "OldJobDecrement",
                                       oldJob);
            singletons.RemoteSingleton(typeof(IStoreSettings),
                                       "Settings",
                                       settingsServer);
        }
        public RemotingConnectorFactory(NotificationFetcherConfig fetcherConfig)
        {
            const string channelName = "remotingConnectorClient";

            _fetcherConfig = fetcherConfig;
            if (System.Runtime.Remoting.Channels.ChannelServices.GetChannel(channelName) == null)
            {
                IDictionary props = new Hashtable();
                props["name"] = channelName;
                props["secure"] = "true";
                props["tokenImpersonationLevel"] = "impersonation";
                var sinkProvier = new System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider();
                var tcc = new System.Runtime.Remoting.Channels.Tcp.TcpClientChannel(props, sinkProvier);
                System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(tcc, false);
            }
        }
Exemplo n.º 3
0
        public RemotingConnectorFactory(NotificationFetcherConfig fetcherConfig)
        {
            const string channelName = "remotingConnectorClient";

            _fetcherConfig = fetcherConfig;
            if (System.Runtime.Remoting.Channels.ChannelServices.GetChannel(channelName) == null)
            {
                IDictionary props = new Hashtable();
                props["name"]   = channelName;
                props["secure"] = "true";
                props["tokenImpersonationLevel"] = "impersonation";
                var sinkProvier = new System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider();
                var tcc         = new System.Runtime.Remoting.Channels.Tcp.TcpClientChannel(props, sinkProvier);
                System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(tcc, false);
            }
        }
Exemplo n.º 4
0
        private static void Run(Func <ReactiveClientContext, Task> action)
        {
            var platform = default(IReactivePlatform);

            try
            {
                platform = new TcpReactivePlatform();

                try
                {
                    var clientProvider = new System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider();
                    var serverProvider = new System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider {
                        TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full
                    };
                    var props = new System.Collections.Hashtable
                    {
                        { "port", 0 },
                        { "name", System.Guid.NewGuid().ToString() },
                        { "typeFilterLevel", System.Runtime.Serialization.Formatters.TypeFilterLevel.Full }
                    };
                    System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(new System.Runtime.Remoting.Channels.Tcp.TcpChannel(props, clientProvider, serverProvider), ensureSecurity: false);

                    platform.StartAsync(CancellationToken.None).Wait();
                    Console.WriteLine("Running demo with the TCP platform.");
                }
#pragma warning disable CA1031 // Do not catch general exception types. (Demo code.)
                catch
                {
                    try { platform.StopAsync(CancellationToken.None).Wait(); }
                    catch { }

                    platform = new InMemoryReactivePlatform();
                    platform.StartAsync(CancellationToken.None).Wait();
                    Console.WriteLine("Running demo with the in-memory platform.");
                }
#pragma warning restore CA1031

                new ReactivePlatformDeployer(platform, new Deployable.CoreDeployable()).Deploy();

                action(platform.CreateClient().Context).Wait();
            }
            finally
            {
                platform?.Dispose();
            }
        }
Exemplo n.º 5
0
        private static void Startup()
        {
            //setup IPC channel
            Hashtable props = new Hashtable();

            System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider clientsink = new System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider();
            System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider serversink = new System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider();

            serversink.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

            props["name"]            = "";
            props["portName"]        = "REMOTING_IPC_CHANNEL_0x" + System.Diagnostics.Process.GetCurrentProcess().Id.ToString("X");
            props["typeFilterLevel"] = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

            m_Channel = new System.Runtime.Remoting.Channels.Ipc.IpcChannel(props, clientsink, serversink);

            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(m_Channel, false);
        }
Exemplo n.º 6
0
        private static void registerChannel(string name, string port)
        {
            System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider serverProv = new System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider();
            serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
            System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider clientProv = new System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider();
            System.Collections.IDictionary properties = new System.Collections.Hashtable();
            properties["name"]     = name;
            properties["priority"] = "20";
            properties["portName"] = port;
            properties["secure"]   = true;
            properties["tokenImpersonationLevel"] = System.Security.Principal.TokenImpersonationLevel.Impersonation;
            properties["includeVersions"]         = false;
            properties["strictBinding"]           = false;
            System.Security.Principal.SecurityIdentifier sidAdmin = new System.Security.Principal.SecurityIdentifier(System.Security.Principal.WellKnownSidType.InteractiveSid, null);
            System.Security.Principal.NTAccount          nt       = (System.Security.Principal.NTAccount)sidAdmin.Translate(typeof(System.Security.Principal.NTAccount));
            progress("registerChannel: " + port + " with authorized group " + nt);
            properties["authorizedGroup"] = nt.Value;

            System.Runtime.Remoting.Channels.Ipc.IpcChannel ipcCh = new System.Runtime.Remoting.Channels.Ipc.IpcChannel(properties, clientProv, serverProv);
            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(ipcCh, true);
        }
Exemplo n.º 7
0
        private static void registerChannel(string name, string port)
        {
            System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider serverProv = new System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider();
            serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
            System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider clientProv = new System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider();
            System.Collections.IDictionary properties = new System.Collections.Hashtable();
            properties["name"] = name;
            properties["priority"] = "20";
            properties["portName"] = port;
            properties["secure"] = true;
            properties["tokenImpersonationLevel"] = System.Security.Principal.TokenImpersonationLevel.Impersonation;
            properties["includeVersions"] = false;
            properties["strictBinding"] = false;
            System.Security.Principal.SecurityIdentifier sidAdmin = new System.Security.Principal.SecurityIdentifier(System.Security.Principal.WellKnownSidType.InteractiveSid, null);
            System.Security.Principal.NTAccount nt = (System.Security.Principal.NTAccount) sidAdmin.Translate(typeof (System.Security.Principal.NTAccount));
            progress("registerChannel: " + port + " with authorized group " + nt);
            properties["authorizedGroup"] = nt.Value;

            System.Runtime.Remoting.Channels.Ipc.IpcChannel ipcCh = new System.Runtime.Remoting.Channels.Ipc.IpcChannel(properties, clientProv, serverProv);
            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(ipcCh, true);
        }