Example #1
0
        public User(OpCore core)
            : base(core)
        {
            InitializeComponent();

            Profile = core.User;

            NameBox.Text = Profile.Settings.UserName;
        }
Example #2
0
        public User(OpCore core)
            : base(core)
        {
            InitializeComponent();

            Profile = core.User;

            NameBox.Text = Profile.Settings.UserName;
        }
Example #3
0
        public Connection(OpCore core)
            : base(core)
        {
            InitializeComponent();

            Core    = core;
            Lookup  = Core.Context.Lookup;
            Profile = Core.User;

            OperationLabel.Text = Core.User.Settings.Operation;

            if (Profile.Settings.OpAccess == AccessType.Secret && !Core.User.Settings.GlobalIM)
            {
                LookupLabel.Visible     = false;
                LookupTcpBox.Visible    = false;
                LookupUdpBox.Visible    = false;
                LookupLanBox.Visible    = false;
                LookupStatusBox.Visible = false;
            }

            OpTcpBox.Text = Core.Network.TcpControl.ListenPort.ToString();
            OpUdpBox.Text = Core.Network.UdpControl.ListenPort.ToString();
            OpLanBox.Text = Core.Network.LanControl.ListenPort.ToString();

            OpStatusBox.Text      = Core.Firewall.ToString();
            OpStatusBox.BackColor = GetStatusColor(Core.Firewall);

            OpTcpBox.KeyPress += new KeyPressEventHandler(PortBox_KeyPress);
            OpUdpBox.KeyPress += new KeyPressEventHandler(PortBox_KeyPress);

            if (Lookup != null)
            {
                LookupTcpBox.Text = Lookup.Network.TcpControl.ListenPort.ToString();
                LookupUdpBox.Text = Lookup.Network.UdpControl.ListenPort.ToString();
                LookupLanBox.Text = Lookup.Network.LanControl.ListenPort.ToString();

                LookupStatusBox.Text      = Lookup.Firewall.ToString();
                LookupStatusBox.BackColor = GetStatusColor(Lookup.Firewall);

                LookupTcpBox.KeyPress += new KeyPressEventHandler(PortBox_KeyPress);
                LookupUdpBox.KeyPress += new KeyPressEventHandler(PortBox_KeyPress);
            }

            // bootstrap contacts
            RefreshBootstrapList();

            // load web caches - depreciated
            foreach (var cache in Core.Network.Cache.WebCaches)
            {
                CacheList.Items.Add(new CacheItem(cache));
            }

            // make sure when user clicks my address with secret network, ip address is right
            Core.Context.FindLocalIP();
        }
Example #4
0
        public Operation(OpCore core) : base(core)
        {
            InitializeComponent();

            Profile = core.User;

            OperationBox.Text = Profile.Settings.Operation;

            if (Profile.Settings.OpAccess == AccessType.Public)
            {
                OperationBox.Enabled = false;
            }
        }
Example #5
0
        public CacheSetup(OpCore core, WebCache cache)
            : base(core)
        {
            InitializeComponent();

            Core    = core;
            Profile = Core.User;

            Cache = cache;

            AddressBox.Text = cache.Address;
            KeyBox.Text     = (cache.AccessKey != null) ? Convert.ToBase64String(cache.AccessKey) : "";
            OpBox.Text      = core.Network.OpID.ToString();
        }
Example #6
0
        public CacheSetup(OpCore core, WebCache cache)
            : base(core)
        {
            InitializeComponent();

            Core = core;
            Profile = Core.User;

            Cache = cache;

            AddressBox.Text = cache.Address;
            KeyBox.Text = (cache.AccessKey != null) ? Convert.ToBase64String(cache.AccessKey) : "";
            OpBox.Text = core.Network.OpID.ToString();
        }
Example #7
0
        public CustomIconForm(OpCore core)
        {
            Profile = core.User;

            // window icon
            Profile_IconUpdate();

            // dialog background color
            if (Application.RenderWithVisualStyles && !GuiUtils.IsRunningOnMono())
                BackColor = System.Drawing.Color.WhiteSmoke;

            // signup for icon updates
            core.User.GuiIconUpdate += Profile_IconUpdate;
        }
Example #8
0
        public CustomIconForm(OpCore core)
        {
            Profile = core.User;


            // window icon
            Profile_IconUpdate();


            // dialog background color
            if (Application.RenderWithVisualStyles && !GuiUtils.IsRunningOnMono())
            {
                BackColor = System.Drawing.Color.WhiteSmoke;
            }


            // signup for icon updates
            core.User.GuiIconUpdate += Profile_IconUpdate;
        }
Example #9
0
        void CreateUserButton_Click(object sender, EventArgs e)
        {
            try
            {
                Directory.CreateDirectory(CacheDir.Path + Path.DirectorySeparatorChar + UserFile);

                if (File.Exists(UserPath))
                {
                    StatusLabel.Text = "User already created";
                    return;
                }

                StatusLabel.Text = "Creating user...";

                OpUser.CreateNew(UserPath, OpName, Username, Password, AccessType.Secret, null, true);

                StatusLabel.Text = "User created";
            }
            catch (Exception ex)
            {
                StatusLabel.Text = "Create error: " + ex.Message;
            }
        }
Example #10
0
File: OpCore.cs Project: swax/DeOps
        // initializing operation network
        public OpCore(DeOpsContext context, string userPath, string pass)
        {
            Context = context;
            Sim = context.Sim;

            StartTime = TimeNow;
            GuiProtocol = new G2Protocol();

            User = new OpUser(userPath, pass, this);
            User.Load(LoadModeType.Settings);

            Network = new DhtNetwork(this, false);

            TunnelID = (ushort)RndGen.Next(1, ushort.MaxValue);

            Test test = new Test(); // should be empty unless running a test

            User.Load(LoadModeType.AllCaches);

            // delete data dirs if frsh start indicated
            if (Sim != null && Sim.Internet.FreshStart)
                for (int service = 1; service < 20; service++ ) // 0 is temp folder, cleared on startup
                {
                    string dirpath = User.RootPath + Path.DirectorySeparatorChar + "Data" + Path.DirectorySeparatorChar + service.ToString();
                    if (Directory.Exists(dirpath))
                        Directory.Delete(dirpath, true);
                }

            if (Sim != null) KeyMax = 32;

            Context.KnownServices[DhtServiceID] = "Dht";
            ServiceBandwidth[DhtServiceID] = new BandwidthLog(RecordBandwidthSeconds);

            // permanent - order is important here
            AddService(new TransferService(this));
            AddService(new LocationService(this));
            AddService(new LocalSync(this));
            AddService(new BuddyService(this));
            AddService(new UpdateService(this));

            if (!User.Settings.GlobalIM)
                AddService(new TrustService(this));

            // optional
            AddService(new IMService(this));
            AddService(new ChatService(this));
            AddService(new ShareService(this));

            if (Type.GetType("Mono.Runtime") == null)
                AddService(new VoiceService(this));

            if (!User.Settings.GlobalIM)
            {
                AddService(new ProfileService(this));
                AddService(new MailService(this));
                AddService(new BoardService(this));
                AddService(new PlanService(this));
                AddService(new StorageService(this));
            }

            if (Sim != null)
                Sim.Internet.RegisterAddress(this);

            CoreThread = new Thread(RunCore);
            CoreThread.Name = User.Settings.Operation + " Thread";

            if (Sim == null || Sim.Internet.TestCoreThread)
                CoreThread.Start();

            #if DEBUG
            DebugWindowsActive = true;
            #endif
        }
Example #11
0
        private CreateUser ReadInvite(string link)
        {
            string[] mainParts = link.Replace("deops://", "").Split('/');

            if (mainParts.Length < 4)
                throw new Exception("Invalid Link");

            // Select John Marshall's Global IM Profile
            string[] nameParts = mainParts[2].Split('@');
            string name = HttpUtility.UrlDecode(nameParts[0]);
            string op = HttpUtility.UrlDecode(nameParts[1]);

            byte[] data = Utilities.HextoBytes(mainParts[3]);
            byte[] pubOpID = Utilities.ExtractBytes(data, 0, 8);
            byte[] encrypted = Utilities.ExtractBytes(data, 8, data.Length - 8);
            byte[] decrypted = null;

            // try opening invite with a currently loaded core
            Context.Cores.LockReading(delegate()
            {
                foreach (var core in Context.Cores)
                    try
                    {
                        if (Utilities.MemCompare(pubOpID, core.User.Settings.PublicOpID))
                            decrypted = core.User.Settings.KeyPair.Decrypt(encrypted, false);
                    }
                    catch { }
            });

            // have user select profile associated with the invite
            while (decrypted == null)
            {
                OpenFileDialog open = new OpenFileDialog();

                open.Title = "Open " + name + "'s " + op + " Profile to Verify Invitation";
                open.InitialDirectory = Application.StartupPath;
                open.Filter = "DeOps Identity (*.dop)|*.dop";

                if (open.ShowDialog() != DialogResult.OK)
                    return null; // user doesnt want to try any more

                GetTextDialog pass = new GetTextDialog("Passphrase", "Enter the passphrase for this profile", "");
                pass.ResultBox.UseSystemPasswordChar = true;

                if (pass.ShowDialog() != DialogResult.OK)
                    continue; // let user choose another profile

                try
                {
                    // open profile
                    var user = new OpUser(open.FileName, pass.ResultBox.Text, null);
                    user.Load(LoadModeType.Settings);

                    // ensure the invitation is for this op specifically
                    if (!Utilities.MemCompare(pubOpID, user.Settings.PublicOpID))
                    {
                        MessageBox.Show("This is not a " + op + " profile");
                        continue;
                    }

                    // try to decrypt the invitation
                    try
                    {
                        decrypted = user.Settings.KeyPair.Decrypt(encrypted, false);
                    }
                    catch
                    {
                        MessageBox.Show("Could not open the invitation with this profile");
                        continue;
                    }
                }
                catch
                {
                    MessageBox.Show("Wrong password");
                }
            }

            CreateUser created = null;

            try
            {
                InvitePackage invite = OpCore.OpenInvite(decrypted, Protocol);

                if(invite != null)
                    created = new CreateUser(App, invite);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return created;
        }
Example #12
0
        private CreateUser ReadInvite(string link)
        {
            string[] mainParts = link.Replace("deops://", "").Split('/');

            if (mainParts.Length < 4)
            {
                throw new Exception("Invalid Link");
            }

            // Select John Marshall's Global IM Profile
            string[] nameParts = mainParts[2].Split('@');
            string   name      = HttpUtility.UrlDecode(nameParts[0]);
            string   op        = HttpUtility.UrlDecode(nameParts[1]);

            byte[] data      = Utilities.HextoBytes(mainParts[3]);
            byte[] pubOpID   = Utilities.ExtractBytes(data, 0, 8);
            byte[] encrypted = Utilities.ExtractBytes(data, 8, data.Length - 8);
            byte[] decrypted = null;

            // try opening invite with a currently loaded core
            Context.Cores.LockReading(delegate()
            {
                foreach (var core in Context.Cores)
                {
                    try
                    {
                        if (Utilities.MemCompare(pubOpID, core.User.Settings.PublicOpID))
                        {
                            decrypted = core.User.Settings.KeyPair.Decrypt(encrypted, false);
                        }
                    }
                    catch { }
                }
            });

            // have user select profile associated with the invite
            while (decrypted == null)
            {
                OpenFileDialog open = new OpenFileDialog();

                open.Title            = "Open " + name + "'s " + op + " Profile to Verify Invitation";
                open.InitialDirectory = Application.StartupPath;
                open.Filter           = "DeOps Identity (*.dop)|*.dop";

                if (open.ShowDialog() != DialogResult.OK)
                {
                    return(null); // user doesnt want to try any more
                }
                GetTextDialog pass = new GetTextDialog("Passphrase", "Enter the passphrase for this profile", "");
                pass.ResultBox.UseSystemPasswordChar = true;

                if (pass.ShowDialog() != DialogResult.OK)
                {
                    continue; // let user choose another profile
                }
                try
                {
                    // open profile
                    var user = new OpUser(open.FileName, pass.ResultBox.Text, null);
                    user.Load(LoadModeType.Settings);

                    // ensure the invitation is for this op specifically
                    if (!Utilities.MemCompare(pubOpID, user.Settings.PublicOpID))
                    {
                        MessageBox.Show("This is not a " + op + " profile");
                        continue;
                    }

                    // try to decrypt the invitation
                    try
                    {
                        decrypted = user.Settings.KeyPair.Decrypt(encrypted, false);
                    }
                    catch
                    {
                        MessageBox.Show("Could not open the invitation with this profile");
                        continue;
                    }
                }
                catch
                {
                    MessageBox.Show("Wrong password");
                }
            }

            CreateUser created = null;

            try
            {
                InvitePackage invite = OpCore.OpenInvite(decrypted, Protocol);

                if (invite != null)
                {
                    created = new CreateUser(App, invite);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return(created);
        }
Example #13
0
        // initializing operation network
        public OpCore(DeOpsContext context, string userPath, string pass)
        {
            Context = context;
            Sim     = context.Sim;

            StartTime   = TimeNow;
            GuiProtocol = new G2Protocol();

            User = new OpUser(userPath, pass, this);
            User.Load(LoadModeType.Settings);

            Network = new DhtNetwork(this, false);

            TunnelID = (ushort)RndGen.Next(1, ushort.MaxValue);

            Test test = new Test(); // should be empty unless running a test

            User.Load(LoadModeType.AllCaches);

            // delete data dirs if frsh start indicated
            if (Sim != null && Sim.Internet.FreshStart)
            {
                for (int service = 1; service < 20; service++)  // 0 is temp folder, cleared on startup
                {
                    string dirpath = User.RootPath + Path.DirectorySeparatorChar + "Data" + Path.DirectorySeparatorChar + service.ToString();
                    if (Directory.Exists(dirpath))
                    {
                        Directory.Delete(dirpath, true);
                    }
                }
            }

            if (Sim != null)
            {
                KeyMax = 32;
            }

            Context.KnownServices[DhtServiceID] = "Dht";
            ServiceBandwidth[DhtServiceID]      = new BandwidthLog(RecordBandwidthSeconds);

            // permanent - order is important here
            AddService(new TransferService(this));
            AddService(new LocationService(this));
            AddService(new LocalSync(this));
            AddService(new BuddyService(this));
            AddService(new UpdateService(this));

            if (!User.Settings.GlobalIM)
            {
                AddService(new TrustService(this));
            }


            // optional
            AddService(new IMService(this));
            AddService(new ChatService(this));
            AddService(new ShareService(this));

            if (Type.GetType("Mono.Runtime") == null)
            {
                AddService(new VoiceService(this));
            }

            if (!User.Settings.GlobalIM)
            {
                AddService(new ProfileService(this));
                AddService(new MailService(this));
                AddService(new BoardService(this));
                AddService(new PlanService(this));
                AddService(new StorageService(this));
            }

            if (Sim != null)
            {
                Sim.Internet.RegisterAddress(this);
            }

            CoreThread      = new Thread(RunCore);
            CoreThread.Name = User.Settings.Operation + " Thread";

            if (Sim == null || Sim.Internet.TestCoreThread)
            {
                CoreThread.Start();
            }

#if DEBUG
            DebugWindowsActive = true;
#endif
        }
Example #14
0
        private void ButtonOK_Click(object sender, EventArgs e)
        {
            // check input data
            try
            {
                ValidateFields();


                // check if file exists
                string filename = OpName + " - " + TextName.Text;

                string path = BrowseLink.Text + Path.DirectorySeparatorChar +
                              filename + Path.DirectorySeparatorChar +
                              filename + ".dop";

                Directory.CreateDirectory(BrowseLink.Text + Path.DirectorySeparatorChar + filename);

                if (File.Exists(path))
                {
                    // A profile for test - swax already exists, overwrite? Yes / No / Cancel
                    DialogResult result = MessageBox.Show("A profile for " + filename + " already exists. Overwrite?", "Overwrite?", MessageBoxButtons.YesNoCancel);

                    if (result == DialogResult.Cancel)
                    {
                        return;
                    }

                    if (result == DialogResult.No)
                    {
                        Close();
                        return;
                    }

                    // All data for test - swax will be lost OK/Cancel
                    result = MessageBox.Show("Are you sure? All previous data will be lost for " + filename, "Overwrite?", MessageBoxButtons.YesNo);

                    if (result == DialogResult.No)
                    {
                        return;
                    }

                    Directory.Delete(Path.GetDirectoryName(path), true);
                }

                byte[] opKey = null;

                if (Invite != null)
                {
                    opKey = Invite.Info.OpID;
                }

                OpUser.CreateNew(path, OpName, TextName.Text, TextPassword.Text, OpAccess, opKey, GlobalIM);

                var ui = App.LoadCore(path, TextPassword.Text);

                if (Invite != null)
                {
                    ui.Core.ProcessInvite(Invite);
                }

                DialogResult = DialogResult.OK;
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message);
            }
        }
Example #15
0
        private bool DoGenerate()
        {
            // load last / male / female names
            List <string> LastNames  = ReadNames(NamesFolderLink.Text + Path.DirectorySeparatorChar + "names_last.txt");
            List <string> FirstNames = ReadNames(NamesFolderLink.Text + Path.DirectorySeparatorChar + "\\names_first.txt");
            List <string> OpNames    = ReadNames(NamesFolderLink.Text + Path.DirectorySeparatorChar + "\\names_ops.txt");

            if (UsersNumeric.Value > LastNames.Count || UsersNumeric.Value > FirstNames.Count)
            {
                MessageBox.Show("Only " + FirstNames.Count.ToString() + " first and " + LastNames.Count.ToString() + " last names loaded");
                return(false);
            }

            if (OrgNumeric.Value > OpNames.Count)
            {
                MessageBox.Show("Only " + OpNames.Count.ToString() + " orgs loaded");
                return(false);
            }

            int users = (int)UsersNumeric.Value;
            int orgs  = (int)OrgNumeric.Value;

            List <byte[]> OpKeys = new List <byte[]>();

            for (int i = 0; i < orgs; i++)
            {
                RNGCryptoServiceProvider rnd = new RNGCryptoServiceProvider();
                OpKeys.Add(Utilities.GenerateKey(rnd, 256));
            }

            Directory.CreateDirectory(OutputFolderLink.Text);

            // choose random name combos to create profiles for
            string name = "";

            GenProgress.Value   = 0;
            GenProgress.Maximum = users;

            for (int i = 0; i < users; i++)
            {
                name = FirstNames[Rnd.Next(FirstNames.Count)] + " " + LastNames[Rnd.Next(LastNames.Count)];

                // create profile
                int index = Rnd.Next(0, orgs);

                string filename = OpNames[index] + " - " + name;
                string path     = OutputFolderLink.Text + Path.DirectorySeparatorChar + filename + Path.DirectorySeparatorChar + filename + ".dop";
                Directory.CreateDirectory(OutputFolderLink.Text + Path.DirectorySeparatorChar + filename);
                string password = name.Split(' ')[0].ToLower(); // lower case first name is password

                var access = SecretNetworkCheckBox.Checked ? AccessType.Secret : AccessType.Private;

                OpUser.CreateNew(path, OpNames[index], name, password, access, OpKeys[index], false);

                if (CreateGlobal.Checked)
                {
                    filename = "Global IM - " + name;
                    path     = OutputFolderLink.Text + Path.DirectorySeparatorChar + filename + Path.DirectorySeparatorChar + filename + ".dop";
                    Directory.CreateDirectory(OutputFolderLink.Text + Path.DirectorySeparatorChar + filename);
                    OpUser.CreateNew(path, "Global IM", name, password, AccessType.Secret, null, true);
                }

                GenProgress.Value++;
            }

            return(true);
        }
Example #16
0
        public Connection(OpCore core)
            : base(core)
        {
            InitializeComponent();

            Core = core;
            Lookup = Core.Context.Lookup;
            Profile = Core.User;

            OperationLabel.Text = Core.User.Settings.Operation;

            if (Profile.Settings.OpAccess == AccessType.Secret && !Core.User.Settings.GlobalIM)
            {
                LookupLabel.Visible = false;
                LookupTcpBox.Visible = false;
                LookupUdpBox.Visible = false;
                LookupLanBox.Visible = false;
                LookupStatusBox.Visible = false;
            }

            OpTcpBox.Text = Core.Network.TcpControl.ListenPort.ToString();
            OpUdpBox.Text = Core.Network.UdpControl.ListenPort.ToString();
            OpLanBox.Text = Core.Network.LanControl.ListenPort.ToString();

            OpStatusBox.Text = Core.Firewall.ToString();
            OpStatusBox.BackColor = GetStatusColor(Core.Firewall);

            OpTcpBox.KeyPress += new KeyPressEventHandler(PortBox_KeyPress);
            OpUdpBox.KeyPress += new KeyPressEventHandler(PortBox_KeyPress);

            if (Lookup != null)
            {
                LookupTcpBox.Text = Lookup.Network.TcpControl.ListenPort.ToString();
                LookupUdpBox.Text = Lookup.Network.UdpControl.ListenPort.ToString();
                LookupLanBox.Text = Lookup.Network.LanControl.ListenPort.ToString();

                LookupStatusBox.Text = Lookup.Firewall.ToString();
                LookupStatusBox.BackColor = GetStatusColor(Lookup.Firewall);

                LookupTcpBox.KeyPress += new KeyPressEventHandler(PortBox_KeyPress);
                LookupUdpBox.KeyPress += new KeyPressEventHandler(PortBox_KeyPress);
            }

            // bootstrap contacts
            RefreshBootstrapList();

            // load web caches - depreciated
            foreach (var cache in Core.Network.Cache.WebCaches)
                CacheList.Items.Add(new CacheItem(cache));

            // make sure when user clicks my address with secret network, ip address is right
            Core.Context.FindLocalIP();
        }