public TcpHandler(DhtNetwork network) { Network = network; Core = Network.Core; Initialize(); }
public ChatMessage(OpCore core, RudpSession session, ChatText text) { UserID = session.UserID; ClientID = session.ClientID; TimeStamp = core.TimeNow; Text = text.Text; Format = text.Format; }
public ChatMessage(OpCore core, string text, TextFormat format) { UserID = core.UserID; ClientID = core.Network.Local.ClientID; TimeStamp = core.TimeNow; Text = text; Format = format; }
public MailUI(CoreUI ui, OpService service) { UI = ui; Core = ui.Core; Mail = service as MailService; Mail.ShowCompose += Mail_ShowCompose; }
public long TimeEllapsed(OpCore core) { if (TimeSent == 0) { return(0); } return((core.TimeNow.Ticks - TimeSent) / TimeSpan.TicksPerMillisecond); }
public User(OpCore core) : base(core) { InitializeComponent(); Profile = core.User; NameBox.Text = Profile.Settings.UserName; }
public UdpHandler(DhtNetwork network) { Network = network; Core = network.Core; Bandwidth = new BandwidthLog(Core.RecordBandwidthSeconds); Initialize(); }
public InviteForm(OpCore core) : base(core) { InitializeComponent(); Core = core; HelpLabel.Text = HelpLabel.Text.Replace("<op>", Core.User.Settings.Operation); }
public void Logout(OpCore core) { core.Exit(); if (InstanceChange != null) { InstanceChange(core.Sim, InstanceChangeType.Update); } }
public void AddCache(string link) { // find core to add cache to if (link.StartsWith("deops://")) { link = link.Substring(8); } else { throw new Exception("Invalid Link"); } string[] parts = link.Split('/', ':'); if (parts.Length < 7 || parts[1] != "bootstrap") { throw new Exception("Invalid Link"); } // match op pub key with key in link, tell user if its for the wrong app var pubOpId = Utilities.HextoBytes(parts[2]); OpCore found = null; if (pubOpId == null && Lookup != null) { found = Lookup; // add to lookup network cache } else { Cores.SafeForEach(c => { if (Utilities.MemCompare(pubOpId, c.User.Settings.PublicOpID)) { found = c; // add cache to that core } }); } // alert user if bootstrap address does not match any available networks, give network name if (found == null) { var opName = HttpUtility.UrlDecode(parts[0]); throw new Exception(string.Format("The link entered is for the {0} network which is not loaded.", opName)); } var userid = BitConverter.ToUInt64(Utilities.HextoBytes(parts[3]), 0); var address = IPAddress.Parse(parts[4]); var tcpPort = ushort.Parse(parts[5]); var udpPort = ushort.Parse(parts[6]); byte type = found.Network.IsLookup ? IdentityPacket.LookupCachedIP : IdentityPacket.OpCachedIP; found.Network.Cache.AddSavedContact( new CachedIP(type, new DhtContact(userid, 0, address, tcpPort, udpPort), true)); }
public ListInstanceItem(OpCore core) { Core = core; UI = new CoreUI(core); Instance = core.Sim; Core.Exited += Core_Exited; Refresh(); }
public PostMessage(BoardService board, ulong id, uint project) { InitializeComponent(); Core = board.Core; Board = board; UserID = id; ProjectID = project; }
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(); }
public static FileLink Decode(string text, OpCore core) { FileLink link = new FileLink(); if (!text.StartsWith("deops://")) { throw new Exception("Invalid Link"); } string[] parts = text.Substring(8).Split('/'); if (parts.Length < 5) { throw new Exception("Invalid Link"); } if (parts[1] != "file") { throw new Exception("Invalid Link"); } link.FileName = HttpUtility.UrlDecode(parts[2]); byte[] endtag = Utilities.FromBase64String(parts[4]); if (endtag.Length < (8 + 8 + 20 + 32)) { throw new Exception("Invalid Link"); } link.PublicOpID = Utilities.ExtractBytes(endtag, 0, 8); byte[] cryptTag = Utilities.ExtractBytes(endtag, 8, endtag.Length - 8); if (core != null) { cryptTag = Utilities.DecryptBytes(cryptTag, cryptTag.Length, core.Network.OpCrypt.Key); link.Size = BitConverter.ToInt64(Utilities.ExtractBytes(cryptTag, 0, 8), 0); link.Hash = Utilities.ExtractBytes(cryptTag, 8, 20); link.Key = Utilities.ExtractBytes(cryptTag, 8 + 20, 32); if (parts.Length >= 6) { link.Sources = Utilities.FromBase64String(parts[5]); if (link.Sources != null) { link.Sources = Utilities.DecryptBytes(link.Sources, link.Sources.Length, core.Network.OpCrypt.Key); } } } return(link); }
public VersionedCache(DhtNetwork network, uint service, uint type, bool localSync) { Core = network.Core; Network = network; Store = network.Store; Service = service; DataType = type; LocalSync = localSync; GlobalIM = Core.User.Settings.GlobalIM; CachePath = Core.User.RootPath + Path.DirectorySeparatorChar + "Data" + Path.DirectorySeparatorChar + Service.ToString() + Path.DirectorySeparatorChar + DataType.ToString(); HeaderPath = CachePath + Path.DirectorySeparatorChar + Utilities.CryptFilename(Core, "VersionedFileHeaders"); Directory.CreateDirectory(CachePath); LocalKey = Core.User.Settings.FileKey; Core.SecondTimerEvent += Core_SecondTimer; Core.MinuteTimerEvent += Core_MinuteTimer; Network.CoreStatusChange += new StatusChange(Network_StatusChange); Store.StoreEvent[Service, DataType] += new StoreHandler(Store_Local); // if local sync used then it will handle all replication if (LocalSync && !GlobalIM) { Store.ReplicateEvent[Service, DataType] += new ReplicateHandler(Store_Replicate); Store.PatchEvent[Service, DataType] += new PatchHandler(Store_Patch); } Network.Searches.SearchEvent[Service, DataType] += new SearchRequestHandler(Search_Local); Core.Transfers.FileSearch[Service, DataType] += new FileSearchHandler(Transfers_FileSearch); Core.Transfers.FileRequest[Service, DataType] += new FileRequestHandler(Transfers_FileRequest); if (!LocalSync) { Core.Sync.GetTag[Service, DataType] += new GetLocalSyncTagHandler(LocalSync_GetTag); Core.Sync.TagReceived[Service, DataType] += new LocalSyncTagReceivedHandler(LocalSync_TagReceived); } if (Core.Sim != null) { PruneSize = 16; } }
public ProfileView(ProfileService profile, ulong id, uint project) { InitializeComponent(); Profiles = profile; Core = profile.Core; Trust = Core.Trust; UserID = id; ProjectID = project; }
public TransferView(TransferService service) { InitializeComponent(); Core = service.Core; Service = service; #if DEBUG Service.Logging = true; #endif }
public Dictionary <int, Tuple <int, int> > MaxVolume = new Dictionary <int, Tuple <int, int> >(); // window, volume<in,out> public VoiceService(OpCore core) { Core = core; Network = core.Network; Core.SecondTimerEvent += Core_SecondTimer; Network.RudpControl.SessionData[ServiceID, 0] += new SessionDataHandler(Session_Data); Network.LightComm.Data[ServiceID, 0] += new LightDataHandler(LightComm_ReceiveData); LastUpdate.Start(); }
public OpCore LoadCore(string userPath, string pass) { var core = new OpCore(this, userPath, pass); Cores.SafeAdd(core); core.Exited += RemoveCore; CheckLookup(); return(core); }
public EditProfile(ProfileService control, ProfileView view) { InitializeComponent(); Core = control.Core; Links = Core.Trust; Profiles = control; MainView = view; TextFields = new Dictionary <string, string>(view.TextFields); FileFields = new Dictionary <string, string>(view.FileFields); }
public RemoveLinks(OpCore core, List <ulong> ids) : base(core) { InitializeComponent(); PersonIDs = ids; foreach (ulong id in PersonIDs) { PeopleList.Items.Add(new RemoveItem(id, core.GetName(id))); } }
public DhtSearch(DhtSearchControl control, UInt64 targetID, string name, uint service, uint datatype) { Core = control.Core; Network = control.Network ; Searches = control; TargetID = targetID; Name = name; Service = service; DataType = datatype; SearchID = (uint) Core.RndGen.Next(1, int.MaxValue); }
public DhtSearch(DhtSearchControl control, UInt64 targetID, string name, uint service, uint datatype) { Core = control.Core; Network = control.Network; Searches = control; TargetID = targetID; Name = name; Service = service; DataType = datatype; SearchID = (uint)Core.RndGen.Next(1, int.MaxValue); }
public IdentityForm(OpCore core, ulong user) { InitializeComponent(); string name = core.GetName(user); HeaderLabel.Text = HeaderLabel.Text.Replace("<name>", name); HelpLabel.Text = HelpLabel.Text.Replace("<name>", name); LinkBox.Text = core.GetIdentity(user); }
public UpnpSetup(OpCore core) { InitializeComponent(); Core = core; UPnP = core.Network.UPnPControl; UPnP.Logging = true; UPnP.Log.SafeClear(); RefreshInterface(); }
public Operation(OpCore core) : base(core) { InitializeComponent(); Profile = core.User; OperationBox.Text = Profile.Settings.Operation; if (Profile.Settings.OpAccess == AccessType.Public) { OperationBox.Enabled = false; } }
public void UnregisterAddress(OpCore core) { if (core.Network.IsLookup) { TcpEndPoints.Remove(new IPEndPoint(core.Sim.RealIP, core.Network.Lookup.Ports.Tcp)); UdpEndPoints.Remove(new IPEndPoint(core.Sim.RealIP, core.Network.Lookup.Ports.Udp)); } else { TcpEndPoints.Remove(new IPEndPoint(core.Sim.RealIP, core.User.Settings.TcpPort)); UdpEndPoints.Remove(new IPEndPoint(core.Sim.RealIP, core.User.Settings.UdpPort)); } }
private void Click_Disconnect(object sender, EventArgs e) { foreach (ListInstanceItem item in ListInstances.SelectedItems) { if (item.Core != null) { OpCore core = item.Core; item.Core = null; // remove list item reference Sim.Logout(core); } } }
public LookupService(OpCore core) { Core = core; Network = core.Network; LookupCache = new TempCache(Network, ServiceID, DataTypeCache); // specify time out // specify how many results to send back // send back newest results? // put ttl }
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(); }
public DhtRouting(DhtNetwork network) { Core = network.Core; Network = network; if (Core.Sim != null) { ContactsPerBucket = 8; } LocalRoutingID = Network.Local.UserID ^ Network.Local.ClientID; BucketList.Add(new DhtBucket(this, 0, true)); }
public static string CryptFilename(OpCore core, string name) { // hash, base64 name with ~ instead of /, use for link as well byte[] salt = Utilities.ExtractBytes(core.User.Settings.FileKey, 0, 4); byte[] final = Utilities.CombineArrays(salt, UTF8Encoding.UTF8.GetBytes(name)); SHA1Managed sha1 = new SHA1Managed(); byte[] hash = new SHA1Managed().ComputeHash(final); return(Utilities.ToBase64String(hash)); }
public LanHandler(DhtNetwork network) { Network = network; Core = network.Core; // we need to listen on a static lan port common to all nodes in the operation // use the opkey to derive this common port byte[] hash = new SHA1Managed().ComputeHash(Network.OpCrypt.Key); ListenPort = BitConverter.ToUInt16(hash, 0); if (ListenPort < 2000) ListenPort += 2000; if (Core.Sim != null) return; LanSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); LanSocket.EnableBroadcast = true; // listen - cant retry because listen port must be the same for everyone try { LanSocket.Bind( new IPEndPoint( System.Net.IPAddress.Any, ListenPort) ); EndPoint tempSender = (EndPoint) new IPEndPoint(IPAddress.Any, 0); LanSocket.BeginReceiveFrom(ReceiveBuff, 0, ReceiveBuff.Length, SocketFlags.None, ref tempSender, new AsyncCallback(UdpSocket_Receive), LanSocket); Network.UpdateLog("Network", "Listening for LAN on port " + ListenPort.ToString()); } catch(Exception ex) { Network.UpdateLog("Exception", "LanHandler::LanHandler: " + ex.Message); } }
public long TimeEllapsed(OpCore core) { if (TimeSent == 0) return 0; return (core.TimeNow.Ticks - TimeSent) / TimeSpan.TicksPerMillisecond; }
public DhtSearchControl(DhtNetwork network) { Network = network; Core = Network.Core; Routing = network.Routing; }
internal SharingService(OpCore core) { Core = core; Network = core.Network; string rootPath = Core.User.RootPath + Path.DirectorySeparatorChar + "Data" + Path.DirectorySeparatorChar + ServiceID.ToString() + Path.DirectorySeparatorChar; SharePath = rootPath + DataTypeShare.ToString() + Path.DirectorySeparatorChar; Directory.CreateDirectory(SharePath); PublicPath = rootPath + DataTypePublic.ToString() + Path.DirectorySeparatorChar; Directory.CreateDirectory(PublicPath); DownloadPath = Core.User.RootPath + Path.DirectorySeparatorChar + "Downloads" + Path.DirectorySeparatorChar; Core.SecondTimerEvent += new TimerHandler(Core_SecondTimer); Core.MinuteTimerEvent += new TimerHandler(Core_MinuteTimer); // data Network.RudpControl.SessionUpdate += new SessionUpdateHandler(Session_Update); Network.RudpControl.SessionData[ServiceID, DataTypeSession] += new SessionDataHandler(Session_Data); Core.Transfers.FileSearch[ServiceID, DataTypeShare] += new FileSearchHandler(Transfers_FileSearch); Core.Transfers.FileRequest[ServiceID, DataTypeShare] += new FileRequestHandler(Transfers_FileRequest); Core.Transfers.FileSearch[ServiceID, DataTypePublic] += new FileSearchHandler(Transfers_PublicSearch); Core.Transfers.FileRequest[ServiceID, DataTypePublic] += new FileRequestHandler(Transfers_PublicRequest); // location Network.Store.StoreEvent[ServiceID, DataTypeLocation] += new StoreHandler(Store_Locations); Network.Searches.SearchEvent[ServiceID, DataTypeLocation] += new SearchRequestHandler(Search_Locations); Local = new ShareCollection(Core.UserID); Collections.SafeAdd(Core.UserID, Local); LoadHeaders(); }
// outbound public TcpConnect(TcpHandler control, DhtAddress address, ushort tcpPort) { Debug.Assert(address.UserID != 0); TcpControl = control; Network = TcpControl.Network; Core = TcpControl.Core; Bandwidth = new BandwidthLog(Core.RecordBandwidthSeconds); Outbound = true; RemoteIP = address.IP; TcpPort = tcpPort; UdpPort = address.UdpPort; UserID = address.UserID; try { IPEndPoint endpoint = new IPEndPoint(RemoteIP, TcpPort); if (Core.Sim != null) { Core.Sim.Internet.SendPacket(SimPacketType.TcpConnect, Network, null, endpoint, this); return; } TcpSocket = new Socket(address.IP.AddressFamily, SocketType.Stream, ProtocolType.Tcp); TcpSocket.BeginConnect((EndPoint)endpoint, new AsyncCallback(Socket_Connect), TcpSocket); } catch (Exception ex) { LogException("TcpSocket", ex.Message); Disconnect(); } }
// inbound public TcpConnect(TcpHandler control) { TcpControl = control; Network = TcpControl.Network; Core = TcpControl.Core; Bandwidth = new BandwidthLog(Core.RecordBandwidthSeconds); }
public RudpSocket(RudpSession session, bool listening) { Session = session; Core = session.Core; Network = Session.Network; Bandwidth = new BandwidthLog(Core.RecordBandwidthSeconds); Listening = listening; PeerID = (ushort)Core.RndGen.Next(1, ushort.MaxValue); lock (Session.RudpControl.SocketMap) Session.RudpControl.SocketMap[PeerID] = this; }
public DhtNetwork(OpCore core, bool lookup) { Core = core; IsLookup = lookup; Cache = new OpCache(this); // lookup config loads cache entries if (IsLookup) { Core.Context.LookupConfig.Load(this); Lookup = Core.Context.LookupConfig; } Local = new DhtClient(); Local.UserID = IsLookup ? Lookup.Ports.UserID : Utilities.KeytoID(Core.User.Settings.KeyPublic); Local.ClientID = (ushort)Core.RndGen.Next(1, ushort.MaxValue); OpID = Utilities.KeytoID(IsLookup ? LookupKey : Core.User.Settings.OpKey); OpCrypt = new RijndaelManaged(); // load encryption if (IsLookup) OpCrypt.Key = LookupKey; else OpCrypt.Key = Core.User.Settings.OpKey; LocalAugmentedKey = GetAugmentedKey(Local.UserID); Protocol = new G2Protocol(); TcpControl = new TcpHandler(this); UdpControl = new UdpHandler(this); LanControl = new LanHandler(this); RudpControl = new RudpHandler(this); LightComm = new LightCommHandler(this); UPnPControl = new UPnPHandler(this); Routing = new DhtRouting(this); Store = new DhtStore(this); Searches = new DhtSearchControl(this); }