예제 #1
0
        private void mnuProfileSettings_Click(object sender, EventArgs e)
        {
            using (frmSettings frm = new frmSettings(_node, Path.GetDirectoryName(_profileFilePath), _isPortableApp))
            {
                if (frm.ShowDialog(this) == DialogResult.OK)
                {
                    if (frm.PasswordChangeRequest)
                    {
                        _node.ChangePassword(frm.Password);
                    }

                    _node.DownloadFolder                   = frm.DownloadFolder;
                    _node.LocalServicePort                 = frm.Port;
                    _node.AllowInboundInvitations          = frm.AllowInboundInvitations;
                    _node.AllowOnlyLocalInboundInvitations = frm.AllowOnlyLocalInboundInvitations;
                    _node.EnableUPnP = frm.EnableUPnP;

                    if (frm.EnableProxy)
                    {
                        _node.ConfigureProxy(frm.ProxyType, frm.ProxyAddress, frm.ProxyPort, frm.ProxyCredentials);
                    }
                    else
                    {
                        _node.DisableProxy();
                    }

                    SaveProfile();
                }
            }
        }
예제 #2
0
        private void CreateAndStartProfile()
        {
            if (_createProfileWindowShown)
            {
                return;
            }

            _createProfileWindowShown = true;

            using (frmCreateProfile frm = new frmCreateProfile())
            {
                frm.Activate();

                if (frm.ShowDialog(this) == DialogResult.OK)
                {
                    int localServicePort;

                    if (frm.NodeType == MeshNodeType.P2P)
                    {
                        localServicePort = (new Random()).Next(10000, 65000); //fixed random port for p2p
                    }
                    else
                    {
                        localServicePort = 0; //new random port at startup for Tor node
                    }
                    MeshNode node = new MeshNode(frm.NodeType, frm.PrivateKey, SecureChannelCipherSuite.DHE2048_RSA2048_WITH_AES256_CBC_HMAC_SHA256, Convert.ToUInt16(localServicePort), frm.ProfileDisplayName, _profileFolder, GetDownloadFolder(), _torController);

                    if (frm.NodeType == MeshNodeType.P2P)
                    {
                        //create default local network group for LAN user discovery
                        node.CreateGroupChat("Local Network", "", true);
                    }

                    string profileFilePath = Path.Combine(_profileFolder, frm.ProfileDisplayName + ".profile");

                    using (FileStream fS = new FileStream(profileFilePath, FileMode.Create, FileAccess.ReadWrite))
                    {
                        node.ChangePassword(frm.ProfilePassword);
                        node.SaveTo(fS);
                    }

                    LoadProfileMainForm(frm.ProfileDisplayName, node, profileFilePath);
                }
                else
                {
                    if (cmbProfiles.Items.Count > 0)
                    {
                        this.Show();
                        this.Activate();
                    }
                }
            }

            _createProfileWindowShown = false;
        }