// 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 }
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); }
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; }
// 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 }