public void add_connection(RemoteHost sender, RemoteHost receiver, bool IsSync)
        {
            try
            {
                if (IsSync)
                {
                    this.receiver = receiver;
                    this.sender = sender;
                    if (this.List_dataconnection.Exists(serch_connection))
                    {
                        throw new Exception("接続が存在します");
                    }

                    this.debugwindow.DebugLog = "[DataConnectionServer]データシンクロ接続を追加します.送信側リモートポート:" + sender.remotePort.ToString() + "受信側リモートポート:" + receiver.remotePort.ToString();
                    this.List_dataconnection.Add(new MyDataConnectionSync(sender, receiver));
                }
                else
                {
                    this.receiver = receiver;
                    this.sender = sender;
                    if (this.List_dataconnection.Exists(serch_connection))
                    {
                        throw new Exception("接続が存在します");
                    }

                    this.debugwindow.DebugLog = "[DataConnectionServer]データ接続を追加します.送信側リモートポート:" + sender.remotePort.ToString() + "受信側リモートポート:" + receiver.remotePort.ToString();
                    this.List_dataconnection.Add(new MyDataConnection(sender, receiver));
                }
            }
            catch (Exception ex)
            {
                this.debugwindow.DebugLog = "[" + this.ToString() + "]" + ex.Message;
            }
        }
Esempio n. 2
0
        public MyDataConnection(RemoteHost sender, RemoteHost receiver)
        {
            this.Sender = sender;
            this.Receiver = receiver;

            this.Sender.ConnectionHost = this.Receiver;
            this.Receiver.ConnectionHost = this.Sender;
            this.IsConnectSync = false;
        }
        public MyDataConnectionSync(RemoteHost sender, RemoteHost receiver)
            : base(sender,receiver)
        {
            if (this.RECEIVER == null) return;
            if (this.SENDER == null) return;

            this.Sender.DataReceived += Sender_DataReceived;
            this.Receiver.IsSyncSend = true;
            this.IsConnectSync = true;
        }
Esempio n. 4
0
 public override string ToString()
 {
     if (RemoteHost.IsNullOrWhiteSpace())
     {
         return($"UDP {LocalHost}:{LocalPort}");
     }
     else
     {
         return($"UDP {LocalHost}:{LocalPort}=>{RemoteHost}:{RemotePort}");
     }
     //return $"udp://{LocalHost}:{LocalPort}?rhost={RemoteHost}&rport={RemotePort}";
 }
Esempio n. 5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            txtName.Text = txtName.Text.Trim();
            if (txtName.TextLength <= 0)
            {
                MetroMessageBox.Show(this, "请填写名称!");
                txtName.Focus();
                txtName.SelectAll();
                return;
            }

            if (!chIsParent.Checked && cbParent.SelectedIndex < 0)
            {
                MetroMessageBox.Show(this, "请选择父级!");
                cbParent.DroppedDown = true;
                return;
            }

            var host = new RemoteHost
            {
                Name = txtName.Text,
                Sort = Convert.ToInt32(numSort.Value),
            };

            if (!chIsParent.Checked)
            {
                host.ParentId      = Convert.ToInt32(cbParent.SelectedValue);
                host.Address       = txtAddress.Text.Trim();
                host.Port          = Convert.ToInt32(numPort.Value);
                host.User          = txtUser.Text.Trim();
                host.Pwd           = txtPwd.Text;
                host.RemoteProgram = txtRemoteProgram.Text.Trim();

                host.Ext.ConnectSession0 = chConnectSession0.Checked;
                host.Ext.ShareAllDisk    = chShareAllDisk.Checked;
                host.Ext.ShareDiskList   = flpDisks.Controls.OfType <MetroCheckBox>().Where(ch => ch.Checked)
                                           .Select(ch => ch.Text).ToList();

                host.ExtJson = JsonConvert.SerializeObject(host.Ext);
            }

            Db.Connection.Execute(
                IsModify
                    ? @"UPDATE RemoteHost SET Name=@Name,Address=@Address,Port=@Port,User=@User,Pwd=@Pwd,Sort=@Sort,ParentId=@ParentId,
                        RemoteProgram=@RemoteProgram,ExtJson=@ExtJson WHERE Id=" + RemoteHost.Id
                    : @"INSERT INTO RemoteHost(Name,Address,Port,User,Pwd,Sort,ParentId,RemoteProgram,ExtJson) 
                        VALUES(@Name,@Address,@Port,@User,@Pwd,@Sort,@ParentId,@RemoteProgram,@ExtJson)",
                host);


            DialogResult = DialogResult.OK;
        }
        /// <summary>
        /// The Step operation records the occurrence of an element by increasing the element's height on the binomial ladder.
        /// It does this by identify the shard of the filter array associated with the element,
        /// fetching the H elements within that shard associated with the element (the element's rungs),
        /// and setting one of the elements with value 0 (a rung above the element) to have value 1 (to put it below the element).
        /// It then clears two random elements from the entire array (not just the shard).
        /// If none of the H rungs associated with an element have value 0, Step will instead set two random elements from
        /// within the full array to have value 1.
        /// </summary>
        /// <param name="key">The element to take a step for.</param>
        /// <param name="heightOfLadderInRungs">If set, use a binomial ladder of this height rather than the default height.
        /// (Must not be greater than the default height that the binmomial ladder was initialized with.)</param>
        /// <param name="timeout"></param>
        /// <param name="cancellationToken"></param>
        /// <returns>The height of the element on its binomial ladder before the Step operation executed.  The height of a
        /// element on the ladder is the number of the H elements associated with the element that have value 1.</returns>
        public async Task <int> StepAsync(string key, int?heightOfLadderInRungs = null, TimeSpan?timeout = null, CancellationToken cancellationToken = new CancellationToken())
        {
            DateTime whenAddedUtc;
            int      topOfLadder = heightOfLadderInRungs ?? MaxLadderHeight;

            bool cacheIndicatesTopOfLadder = CacheOfElementsAtTopOfLadder.TryGetValue(key, out whenAddedUtc);

            if (cacheIndicatesTopOfLadder && DateTime.UtcNow - whenAddedUtc < MinimumCacheFreshnessRequired)
            {
                // The cache is fresh and indicates that the element is already at the top of the ladder

                // Since the element is at the top of the lader, if we were to ask the host responsible for this shard to perform this Step,
                // it would clear two random elements from the entire filter and set two random elements from the entire filter.
                // To avoid creating a hot-spot at the host associated with this element, we'll have the client do the two random
                // clears and two random sets on its own.
                AssignRandomBit(1);
                AssignRandomBit(1);
                AssignRandomBit(0);
                AssignRandomBit(0);

                return(topOfLadder);
            }

            // We will first identify the shard associated with this element, and the host responsible for storing that shard
            int        shard = GetShardIndex(key);
            RemoteHost host  = ShardToHostMapping.FindMemberResponsible(shard.ToString());

            // Call the host responsible for the shard to perform the step operation
            int heightBeforeStep = await RestClientHelper.PostAsync <int>(host.Uri, ElementsPath + Uri.EscapeUriString(key),
                                                                          timeout : timeout, cancellationToken : cancellationToken,
                                                                          parameters : (!heightOfLadderInRungs.HasValue)?null : new object[]
            {
                new KeyValuePair <string, int>("heightOfLadderInRungs", topOfLadder)
            });

            if (heightBeforeStep < topOfLadder && cacheIndicatesTopOfLadder)
            {
                // The cache is no longer accurate as the element is no longer at the top of the ladder,
                // so remove the element from the cache
                CacheOfElementsAtTopOfLadder.Remove(key);
            }
            else if (heightBeforeStep == topOfLadder)
            {
                // Store the current element in the cache indicating with the time of this operation
                CacheOfElementsAtTopOfLadder[key] = DateTime.UtcNow;
            }

            // Return the height of the element on the binomial ladder before the Step took place.
            return(heightBeforeStep);
        }
 public void delete_connection(RemoteHost sender, RemoteHost receiver)
 {
     try
     {
         this.debugwindow.DebugLog = "[DataConnectionServer]データ接続を削除します.送信側リモートポート:" + sender.remotePort.ToString() + "受信側リモートポート:" + receiver.remotePort.ToString();
         this.receiver             = receiver;
         this.sender = sender;
         this.List_dataconnection.RemoveAll(serch_connection);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        public void Init()
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath("")
                          .AddJsonFile("appsettings.json");

            builder.AddEnvironmentVariables();
            Configuration = builder.Build();

            sqlConnectionString = Configuration["Data:ConnectionString"];
            string cloudStorageConnectionString = Configuration["Data:StorageConnectionString"];

            _options = new BlockingAlgorithmOptions();

            DbContextOptionsBuilder <DbUserAccountContext> dbOptionsBuilder = new DbContextOptionsBuilder <DbUserAccountContext>();

            dbOptionsBuilder.UseSqlServer(sqlConnectionString);
            dbOptions = dbOptionsBuilder.Options;

            _CloudStorageAccount         = CloudStorageAccount.Parse(cloudStorageConnectionString);
            userAccountControllerFactory = new DbUserAccountControllerFactory(_CloudStorageAccount, dbOptions);
            userAccountController        = userAccountControllerFactory.CreateDbUserAccountController();

            RemoteHost localHost = new RemoteHost {
                Uri = new Uri("http://localhost:35358")
            };
            MaxWeightHashing <RemoteHost> hosts = new MaxWeightHashing <RemoteHost>(Configuration["Data:UniqueConfigurationSecretPhrase"]);

            LoginAttemptClient <DbUserAccount> loginAttemptClient = new LoginAttemptClient <DbUserAccount>(hosts, localHost);

            _UserAccountRepositoryFactory = new DbUserAccountRepositoryFactory(dbOptions);

            BinomialLadderFilter localPasswordBinomialLadderFilter = new BinomialLadderFilter(
                _options.NumberOfBitsInBinomialLadderFilter_N, _options.HeightOfBinomialLadder_H);

            _loginAttemptController = new LoginAttemptController <DbUserAccount>(
                userAccountControllerFactory, _UserAccountRepositoryFactory,
                localPasswordBinomialLadderFilter,
                new MemoryUsageLimiter(), _options);

            //services.AddEntityFramework()
            //    .AddSqlServer()
            //    .AddDbContext<DbUserAccountContext>(opt => opt.UseSqlServer(sqlConnectionString));
            //DbUserAccountContext context = new DbUserAccountContext();

            //var db = new DbContextOptionsBuilder();
            //db.UseInMemoryDatabase();
            //_context = new MyContext(db.Options);
        }
Esempio n. 9
0
        private void SetRunCommand()
        {
            if (hosts.SelectedNode == null)
            {
                return;
            }

            RemoteHost h = hosts.SelectedNode.Tag as RemoteHost;

            if (h != null)
            {
                h.RunCommand = runCommand.Text.Trim();
                m_Core.Config.Serialize(Core.ConfigFilename);
            }
        }
Esempio n. 10
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();

            BlockingAlgorithmOptions options = new BlockingAlgorithmOptions();

            services.AddSingleton <BlockingAlgorithmOptions>(x => options);

            RemoteHost localHost = new RemoteHost {
                Uri = new Uri("http://localhost:35358")
            };

            services.AddSingleton <RemoteHost>(x => localHost);

            MaxWeightHashing <RemoteHost> hosts = new MaxWeightHashing <RemoteHost>(Configuration["Data:UniqueConfigurationSecretPhrase"]);

            hosts.Add("localhost", localHost);
            services.AddSingleton <IDistributedResponsibilitySet <RemoteHost> >(x => hosts);

            string cloudStorageConnectionString     = Configuration["Data:StorageConnectionString"];
            CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(cloudStorageConnectionString);

            services.AddSingleton <CloudStorageAccount>(a => cloudStorageAccount);

            services.AddSingleton <MemoryUsageLimiter, MemoryUsageLimiter>();

            if (hosts.Count > 0)
            {
                DistributedBinomialLadderFilterClient dblfClient = new DistributedBinomialLadderFilterClient(
                    options.NumberOfVirtualNodesForDistributedBinomialLadder,
                    options.HeightOfBinomialLadder_H,
                    hosts,
                    options.PrivateConfigurationKey,
                    options.MinimumBinomialLadderFilterCacheFreshness);
                services.AddSingleton <IBinomialLadderFilter, DistributedBinomialLadderFilterClient>(x => dblfClient);
            }
            else
            {
                BinomialLadderFilter localPasswordBinomialLadderFilter =
                    new BinomialLadderFilter(options.NumberOfBitsInBinomialLadderFilter_N, options.HeightOfBinomialLadder_H);
                services.AddSingleton <IBinomialLadderFilter>(x => localPasswordBinomialLadderFilter);
            }

            LoginAttemptClient <MemoryUserAccount> loginAttemptClient = new LoginAttemptClient <MemoryUserAccount>(hosts, localHost);

            services.AddSingleton <ILoginAttemptClient, LoginAttemptClient <MemoryUserAccount> >(i => loginAttemptClient);
            services.AddSingleton <ILoginAttemptController, LoginAttemptController <MemoryUserAccount> >();
        }
Esempio n. 11
0
        private void hosts_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (selectInProgress)
            {
                return;
            }

            selectInProgress = true;

            runCommand.Text = "";
            hostname.Text   = "";

            deleteHost.Enabled = refreshOne.Enabled = false;
            hostname.Enabled   = addUpdateHost.Enabled = runCommand.Enabled = true;
            addUpdateHost.Text = "Add";

            if (hosts.SelectedNode != null &&
                hosts.SelectedNode.Tag != null)
            {
                RemoteHost host = hosts.SelectedNode.Tag as RemoteHost;

                if (host != null)
                {
                    if (refreshAll.Enabled)
                    {
                        refreshOne.Enabled = true;
                    }

                    if (host.Hostname == "localhost")
                    {
                        hostname.Text   = "";
                        runCommand.Text = "";
                    }
                    else
                    {
                        deleteHost.Enabled = true;
                        runCommand.Text    = host.RunCommand;
                        hostname.Text      = host.Hostname;

                        addUpdateHost.Text = "Update";
                    }
                }
            }

            updateConnectButton();

            selectInProgress = false;
        }
Esempio n. 12
0
        public MyDataConnectionSync(RemoteHost sender, RemoteHost receiver)
            : base(sender, receiver)
        {
            if (this.RECEIVER == null)
            {
                return;
            }
            if (this.SENDER == null)
            {
                return;
            }

            this.Sender.DataReceived += Sender_DataReceived;
            this.Receiver.IsSyncSend  = true;
            this.IsConnectSync        = true;
        }
Esempio n. 13
0
        // we kick off a thread per host to query for any open connections. The
        // interfaces on the C++ side should be thread-safe to cope with this
        private void AddHost(RemoteHost host)
        {
            TreelistView.Node node = new TreelistView.Node(new object[] { host.Hostname, "..." });

            node.Italic = true;
            node.Image  = global::renderdocui.Properties.Resources.hourglass;
            node.Tag    = host;

            hosts.Nodes.Add(node);

            refresh.Enabled = false;

            Thread th = Helpers.NewThread(new ParameterizedThreadStart(LookupHostConnections));

            th.Start(node);
        }
Esempio n. 14
0
        private void connect_Click(object sender, EventArgs e)
        {
            TreelistView.Node node = hosts.SelectedNode;
            if (node.Tag is RemoteConnect)
            {
                ConnectToHost(node);
            }
            else if (node.Tag is RemoteHost)
            {
                RemoteHost host = node.Tag as RemoteHost;

                if (host.ServerRunning)
                {
                    DialogResult res = MessageBox.Show(String.Format("Are you sure you wish to shut down running remote server on {0}?", host.Hostname),
                                                       "Remote server shutdown", MessageBoxButtons.YesNoCancel);

                    if (res == DialogResult.Cancel || res == DialogResult.No)
                    {
                        return;
                    }

                    // shut down
                    try
                    {
                        RemoteServer server = StaticExports.CreateRemoteServer(host.Hostname, 0);
                        server.ShutdownServerAndConnection();
                        hosts.BeginUpdate();
                        SetRemoteServerLive(node, false, false);
                        hosts.EndUpdate();
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Error shutting down remote server", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    updateConnectButton();
                }
                else
                {
                    // try to run
                    refresh.Enabled = false;

                    Thread th = Helpers.NewThread(new ParameterizedThreadStart(RunRemoteServer));
                    th.Start(node);
                }
            }
        }
Esempio n. 15
0
        public void SetUp()
        {
            _remoteHost = Substitute.For <RemoteHost>();

            _sut = new Friends(_remoteHost);

            _observableFriends = new ObservableCollection <Friend>();
            _observableFriends.Add(
                new FriendBuilder()
                .WithId(0)
                .WithName("")
                .WithOnlineStatus(false)
                .WithLastSeen(new DateTime(0001, 1, 1))
                .WithLevel(0)
                .Build()
                );

            _remoteHost.Friends.Returns(_observableFriends);
        }
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            txtName.Text = txtName.Text.Trim();
            if (txtName.TextLength <= 0)
            {
                MetroMessageBox.Show(this, "请填写名称!");
                txtName.Focus();
                txtName.SelectAll();
                return;
            }
            if (!chIsParent.Checked && cbParent.SelectedIndex < 0)
            {
                MetroMessageBox.Show(this, "请选择父级!");
                cbParent.DroppedDown = true;
                return;
            }

            var host = new RemoteHost
            {
                Name = txtName.Text,
                Sort = Convert.ToInt32(numSort.Value),
            };

            if (!chIsParent.Checked)
            {
                host.ParentId      = Convert.ToInt32(cbParent.SelectedValue);
                host.Address       = txtAddress.Text.Trim();
                host.Port          = Convert.ToInt32(numPort.Value);
                host.User          = txtUser.Text.Trim();
                host.Pwd           = txtPwd.Text;
                host.RemoteProgram = txtRemoteProgram.Text.Trim();
            }

            Db.Connection.Execute(
                IsModify
                    ? "UPDATE RemoteHost SET Name=@Name,Address=@Address,Port=@Port,User=@User,Pwd=@Pwd,Sort=@Sort,ParentId=@ParentId,RemoteProgram=@RemoteProgram WHERE Id=" + RemoteHost.Id
                    : "INSERT INTO RemoteHost(Name,Address,Port,User,Pwd,Sort,ParentId,RemoteProgram) VALUES(@Name,@Address,@Port,@User,@Pwd,@Sort,@ParentId,@RemoteProgram)",
                host);


            DialogResult = DialogResult.OK;
        }
Esempio n. 17
0
        private void updateConnectButton()
        {
            if (hosts.SelectedNode != null &&
                hosts.SelectedNode.Tag != null)
            {
                connect.Enabled = true;
                connect.Text    = "Connect to App";

                RemoteHost host = hosts.SelectedNode.Tag as RemoteHost;

                if (host != null)
                {
                    if (host.Hostname == "localhost")
                    {
                        connect.Enabled = false;
                    }
                    else if (host.ServerRunning)
                    {
                        connect.Text = "Shutdown";

                        if (host.Busy && !host.Connected)
                        {
                            connect.Enabled = false;
                        }
                    }
                    else
                    {
                        connect.Text = "Run Server";

                        if (host.RunCommand == "")
                        {
                            connect.Enabled = false;
                        }
                    }
                }
            }
            else
            {
                connect.Enabled = false;
            }
        }
Esempio n. 18
0
        public UserInfo(string local, string logini, RemoteHost remoteHost)
        {
            // On récupère la langue avec laquelle on
            // va répondre au client
            // par défault c'est l'anglais
            string Lang = Util.Nvl(local, Const.LangEN);

            // On défini la langue de l'utilisateur
            SetMessages(Lang);

            SetLogin(logini);
            SetLoginDate();
            SetPassword(null);

            // On indique l'hôte distant qui fait l'appel
            SetRemoteHost(remoteHost);
            // également l'application par laquelle le client est passé
            SetApplication(UserInfo.APPLICATION_NONE);
            // enfin l'action (Encryption ou Décryptage)
            SetAction(UserInfo.ACTION_NONE);
        }
Esempio n. 19
0
        public async Task <int> StepAsync(string key, int?heightOfLadderInRungs = null, TimeSpan?timeout = null, CancellationToken cancellationToken = new CancellationToken())
        {
            DateTime whenAddedUtc;
            int      topOfLadder = heightOfLadderInRungs ?? MaxLadderHeight;

            bool cacheIndicatesTopOfLadder = CacheOfElementsAtTopOfLadder.TryGetValue(key, out whenAddedUtc);

            if (cacheIndicatesTopOfLadder && DateTime.UtcNow - whenAddedUtc < MinimumCacheFreshnessRequired)
            {
                AssignRandomBit(1);
                AssignRandomBit(1);
                AssignRandomBit(0);
                AssignRandomBit(0);

                return(topOfLadder);
            }

            int        shard = GetShardIndex(key);
            RemoteHost host  = ShardToHostMapping.FindMemberResponsible(shard.ToString());

            int heightBeforeStep = await RestClientHelper.PostAsync <int>(host.Uri, ElementsPath + Uri.EscapeUriString(key),
                                                                          timeout : timeout, cancellationToken : cancellationToken,
                                                                          parameters : (!heightOfLadderInRungs.HasValue)?null : new object[]
            {
                new KeyValuePair <string, int>("heightOfLadderInRungs", topOfLadder)
            });

            if (heightBeforeStep < topOfLadder && cacheIndicatesTopOfLadder)
            {
                CacheOfElementsAtTopOfLadder.Remove(key);
            }
            else if (heightBeforeStep == topOfLadder)
            {
                CacheOfElementsAtTopOfLadder[key] = DateTime.UtcNow;
            }

            return(heightBeforeStep);
        }
Esempio n. 20
0
        public void RemoteHostParser1()
        {
            RemoteHost remote1 = RemoteHost.Parse("[email protected]");

            Assert.AreEqual("user", remote1.Username);
            Assert.AreEqual("", remote1.Password);
            Assert.AreEqual("192.168.0.1", remote1.Host);
            Assert.AreEqual(22, remote1.Port);

            RemoteHost remote2 = RemoteHost.Parse("user:p@[email protected]:2244");

            Assert.AreEqual("user", remote2.Username);
            Assert.AreEqual("p@sSw0rD", remote2.Password);
            Assert.AreEqual("ec2-eu-central-1.amazon.aws.com", remote2.Host);
            Assert.AreEqual(2244, remote2.Port);

            RemoteHost remote3 = RemoteHost.Parse(@"mother_fuck-3r:v3ry_str0ng-#\@255.255.255.255:65535");

            Assert.AreEqual(@"mother_fuck-3r", remote3.Username);
            Assert.AreEqual(@"v3ry_str0ng-#\", remote3.Password);
            Assert.AreEqual("255.255.255.255", remote3.Host);
            Assert.AreEqual(65535, remote3.Port);
        }
        public static List <RemoteHost> getRemoteHosts()
        {
            string address = @"net.tcp://";

            List <RemoteHost> hosts = new List <RemoteHost>();


            var remote = from r in XElement.Load("NetConfig.xml").Element("RemoteHosts").Elements("Host")
                         select r;

            foreach (var host in remote)
            {
                RemoteHost h = new RemoteHost();

                h.name       = host.Element("Name").Value;
                h.IP         = host.Element("IP").Value;
                h.port       = host.Element("Port").Value;
                h.netAddress = address + h.IP + ":" + h.port + @"/Remote";

                hosts.Add(h);
            }

            return(hosts);
        }
Esempio n. 22
0
        private static void SetRemoteServerLive(TreelistView.Node node, bool live, bool busy)
        {
            RemoteHost host = node.Tag as RemoteHost;

            host.ServerRunning = live;
            host.Busy          = busy;

            if (host.Hostname == "localhost")
            {
                node.Image      = null;
                node["running"] = "";
            }
            else
            {
                string text = live ? RemoteServerLiveText : RemoteServerDeadText;

                if (host.Connected)
                {
                    text += " (Active Context)";
                }
                else if (host.VersionMismatch)
                {
                    text += " (Version Mismatch)";
                }
                else if (host.Busy)
                {
                    text += " (Busy)";
                }

                node["running"] = text;

                node.Image = live
                    ? global::renderdocui.Properties.Resources.connect
                    : global::renderdocui.Properties.Resources.disconnect;
            }
        }
Esempio n. 23
0
        // we kick off a thread per host to query for any open connections. The
        // interfaces on the C++ side should be thread-safe to cope with this
        private void AddHost(RemoteHost host)
        {
            TreelistView.Node node = new TreelistView.Node(new object[] { host.Hostname, "..." });

            node.Italic = true;
            node.Image  = global::renderdocui.Properties.Resources.hourglass;
            node.Tag    = host;

            hosts.Nodes.Add(node);

            refreshOne.Enabled = refreshAll.Enabled = false;

            {
                lookupMutex.WaitOne();
                lookupsInProgress++;
                lookupMutex.ReleaseMutex();
            }

            Thread th = Helpers.NewThread(new ParameterizedThreadStart(LookupHostConnections));

            th.Start(node);

            UpdateLookupsStatus();
        }
Esempio n. 24
0
        private void AddNewHost()
        {
            string host = hostname.Text.Trim();

            if (host.Length > 0)
            {
                bool found = false;

                StringComparer comp = StringComparer.Create(System.Globalization.CultureInfo.CurrentCulture, true);

                for (int i = 0; i < m_Core.Config.RemoteHosts.Count; i++)
                {
                    if (comp.Compare(m_Core.Config.RemoteHosts[i].Hostname, host.Trim()) == 0)
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    RemoteHost h = new RemoteHost();
                    h.Hostname   = host;
                    h.RunCommand = runCommand.Text;

                    m_Core.Config.RemoteHosts.Add(h);
                    m_Core.Config.Serialize(Core.ConfigFilename);

                    hosts.BeginUpdate();
                    AddHost(h);
                    hosts.EndUpdate();
                }
            }
            hostname.Text = "";
            hostname.Text = host;
        }
Esempio n. 25
0
 public HostInfo(RemoteHost host) : this()
 {
     Host = host;
 }
 public void delete_connection(RemoteHost sender,RemoteHost receiver)
 {
     try
     {
         this.debugwindow.DebugLog = "[DataConnectionServer]データ接続を削除します.送信側リモートポート:" + sender.remotePort.ToString() + "受信側リモートポート:" + receiver.remotePort.ToString();
         this.receiver = receiver;
         this.sender = sender;
         this.List_dataconnection.RemoveAll(serch_connection);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Esempio n. 27
0
        private static void ProcessArgs(String[] args)
        {
            for (int idx = 0; idx < args.Length; idx++)
            {
                switch (args[idx])
                {
                case "-s":
                case "--substitute-path":
                    String[] subst = TakeArg(args, ref idx).Split(new[] { '=' }, 2);
                    if (subst.Length != 2)
                    {
                        throw new ApplicationException("--substitute-path requires next arg to be like '/path/before=/path/after'");
                    }
                    AbsoluteCrosspath[] pair = new AbsoluteCrosspath[2];
                    for (int i = 0; i < 2; ++i)
                    {
                        try {
                            pair[i] = Crosspath.FromString(subst[i]) as AbsoluteCrosspath;
                        }
                        catch (Exception e) {
                            throw new PolymorphismException($"{e.GetType()}: '{subst[i]}' is not a valid absolute path");
                        }
                    }
                    config.Substitutions.Add(new Tuple <AbsoluteCrosspath, AbsoluteCrosspath>(pair[0], pair[1]));
                    break;

                case "-b":
                case "--base-dir":
                    config.BaseDir = AbsoluteCrosspath.FromString(TakeArg(args, ref idx));
                    break;

#if PATH_BASED_FILTERING
                case "--include":
                    config.IncludeFilesFrom.Add(Crosspath.FromString(TakeArg(args, ref idx)));
                    break;

                case "--exclude":
                    config.ExcludeFilesFrom.Add(Crosspath.FromString(TakeArg(args, ref idx)));
                    break;
#endif

                case "-o":
                case "--output-dir":
                    config.Outdir = TakeArg(args, ref idx);
                    break;

                case "-f":
                case "--file":
                    config.InputFile = TakeArg(args, ref idx);
                    break;

                case "-r":
                case "--remote":
                    RemoteHost remote = RemoteHost.Parse(TakeArg(args, ref idx));
                    config.AssignRemote(remote);
                    break;

                case "-D":
                case "--define":
                    config.OverrideDefines.Add(new Define(TakeArg(args, ref idx)));
                    break;

                case "--exclude-compiler":
                    config.ExcludeCompilers.Add(Crosspath.FromString(TakeArg(args, ref idx)));
                    break;

                case "--relax-include-dirs-order":
                    config.RelaxIncludeDirsOrder = true;
                    break;

                case "--randomize-outdir":
                    config.Outdir = Path.Combine(config.Outdir, new Random().Next().ToString("x8"));
                    break;

                case "--open-now":
                    config.OpenSolution = true;
                    break;

                case "--debug":
                    Logger.Level = LogLevel.Debug;
                    break;

                case "--help":
                    ShowHelp();
                    return;

                default:
                    throw new Exception($"Unknown command line parameter '{args[idx]}");
                }
            }
        }
Esempio n. 28
0
 /// <summary>
 /// Syslog a debug message
 /// </summary>
 /// <param name="message">The message to log</param>
 private void LogDebug(string message)
 {
     Parent.LogDebug(RemoteHost.ToString() + ": " + message);
 }
Esempio n. 29
0
 /// <summary>
 /// Syslog an error
 /// </summary>
 /// <param name="message">The message to log</param>
 private void LogError(string message)
 {
     Parent.LogError(RemoteHost.ToString() + ": " + message);
 }
Esempio n. 30
0
        // this function looks up the remote connections and for each one open
        // queries it for the API, target (usually executable name) and if any user is already connected
        private static void LookupHostConnections(object o)
        {
            {
                lookupMutex.WaitOne();
                lookupsInProgress++;
                lookupMutex.ReleaseMutex();
            }

            TreelistView.Node node = o as TreelistView.Node;

            Control p = node.OwnerView;

            while (p.Parent != null)
            {
                p = p.Parent;
            }

            RemoteManager rhs = p as RemoteManager;

            string hostname = node["hostname"] as string;

            string username = System.Security.Principal.WindowsIdentity.GetCurrent().Name;

            RemoteHost host = node.Tag as RemoteHost;

            host.CheckStatus();

            SetRemoteServerLive(node, host.ServerRunning, host.Busy);

            StaticExports.EnumerateRemoteTargets(hostname, (UInt32 i) => {
                try
                {
                    var conn = StaticExports.CreateTargetControl(hostname, i, username, false);

                    if (node.OwnerView.Visible)
                    {
                        string target = conn.Target;
                        string api    = conn.API;
                        string busy   = conn.BusyClient;

                        string running;

                        if (busy != "")
                        {
                            running = String.Format("Running {0}, {1} is connected", api, busy);
                        }
                        else
                        {
                            running = String.Format("Running {0}", api);
                        }

                        node.OwnerView.BeginInvoke((MethodInvoker) delegate
                        {
                            node.OwnerView.BeginUpdate();
                            node.Nodes.Add(new TreelistView.Node(new object[] { target, running })).Tag = new RemoteConnect(hostname, i);
                            node.OwnerView.EndUpdate();
                            node.Expand();
                        });
                    }

                    conn.Shutdown();
                }
                catch (ReplayCreateException)
                {
                }
            });

            if (node.OwnerView.Visible)
            {
                node.OwnerView.BeginInvoke((MethodInvoker) delegate
                {
                    node.OwnerView.BeginUpdate();
                    node.Italic = false;
                    node.OwnerView.EndUpdate();
                });
            }

            {
                lookupMutex.WaitOne();
                lookupsInProgress--;
                lookupMutex.ReleaseMutex();
            }

            if (!rhs.IsDisposed && rhs.Visible)
            {
                rhs.BeginInvoke((MethodInvoker) delegate { rhs.LookupComplete(); });
            }
        }
Esempio n. 31
0
 public RemoteHostTests()
 {
     _remote = new RemoteHost();
 }
Esempio n. 32
0
 protected void SocketServer_HostClosedConnection(object sender, RemoteHost host)
 {
     AddMessage(string.Format("Host : {0} - Status : Closed ", host.Address));
 }
 private void lbCopy_Click(object sender, EventArgs e)
 {
     RemoteHost     = null;
     lbCopy.Visible = false;
 }
Esempio n. 34
0
 /// <summary>
 /// Mise à jour de l'adresse IP
 /// </summary>
 /// <param name="host">Hote distant</param>
 private void SetRemoteHost(RemoteHost host)
 {
     this.RemoteHost = host;
 }