コード例 #1
0
ファイル: GraphForm.cs プロジェクト: RoelofSol/DeOps
        public static void Show(DhtNetwork network)
        {
            var form = new GraphForm(network);

            form.Show();
            form.Activate();
        }
コード例 #2
0
ファイル: LocalSync.cs プロジェクト: RoelofSol/DeOps
        public LocalSync(OpCore core)
        {
            Core = core;
            Network = core.Network;
            Store = Network.Store;
            Core.Sync = this;

            GlobalIM = Core.User.Settings.GlobalIM;

            Network.CoreStatusChange += new StatusChange(Network_StatusChange);

            Core.Locations.GetTag[ServiceID, DataTypeSync] += new GetLocationTagHandler(Locations_GetTag);
            Core.Locations.TagReceived[ServiceID, DataTypeSync] += new LocationTagReceivedHandler(Locations_TagReceived);

            Store.ReplicateEvent[ServiceID, DataTypeSync] += new ReplicateHandler(Store_Replicate);

            Cache = new VersionedCache(Network, ServiceID, DataTypeSync, true);
            Cache.FileAquired += new FileAquiredHandler(Cache_FileAquired);
            Cache.FileRemoved += new FileRemovedHandler(Cache_FileRemoved);
            Cache.Load();

            // if sync file for ourselves does not exist create
            if (!Cache.FileMap.SafeContainsKey(Core.UserID))
                UpdateLocal();
        }
コード例 #3
0
ファイル: TcpHandler.cs プロジェクト: RoelofSol/DeOps
        public TcpHandler(DhtNetwork network)
        {
            Network = network;
            Core = Network.Core;

            Initialize();
        }
コード例 #4
0
ファイル: BoardService.cs プロジェクト: RoelofSol/DeOps
        public BoardService(OpCore core )
        {
            Core       = core;
            Network = Core.Network;
            Protocol = Network.Protocol;
            Store    = Network.Store;
            Trust = Core.Trust;

            Core.SecondTimerEvent += Core_SecondTimer;
            Core.MinuteTimerEvent += Core_MinuteTimer;

            Network.CoreStatusChange += new StatusChange(Network_StatusChange);

            Store.StoreEvent[ServiceID, 0] += new StoreHandler(Store_Local);
            Store.ReplicateEvent[ServiceID, 0] += new ReplicateHandler(Store_Replicate);
            Store.PatchEvent[ServiceID, 0] += new PatchHandler(Store_Patch);

            Network.Searches.SearchEvent[ServiceID, 0] += new SearchRequestHandler(Search_Local);

            Core.Transfers.FileSearch[ServiceID, 0] += new FileSearchHandler(Transfers_FileSearch);
            Core.Transfers.FileRequest[ServiceID, 0] += new FileRequestHandler(Transfers_FileRequest);

            if (Core.Sim != null)
                PruneSize = 16;

            LocalFileKey = Core.User.Settings.FileKey;

            BoardPath = Core.User.RootPath + Path.DirectorySeparatorChar + "Data" + Path.DirectorySeparatorChar + ServiceID.ToString();

            if (!Directory.Exists(BoardPath))
                Directory.CreateDirectory(BoardPath);

            // get available board header targets
            string[] directories = Directory.GetDirectories(BoardPath);

            SortedDictionary<ulong, ulong> targets = new SortedDictionary<ulong, ulong>(); // key distance to self, value target

            foreach (string path in directories)
            {
                string dir = Path.GetFileName(path); // gets dir name

                ulong id = BitConverter.ToUInt64(Utilities.FromBase64String(dir), 0);

                targets[Core.UserID ^ id] = id;
            }

            // load closest targets
            int loaded = 0;
            foreach (ulong id in targets.Values)
            {
                LoadHeader(id);

                loaded++;
                if (loaded == PruneSize)
                    break;
            }

            Loading = false;
        }
コード例 #5
0
ファイル: UdpHandler.cs プロジェクト: RoelofSol/DeOps
        public UdpHandler(DhtNetwork network)
        {
            Network = network;
            Core = network.Core;

            Bandwidth = new BandwidthLog(Core.RecordBandwidthSeconds);

            Initialize();
        }
コード例 #6
0
ファイル: DhtSearch.cs プロジェクト: nandub/DeOps
        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);
        }
コード例 #7
0
ファイル: LookupService.cs プロジェクト: RoelofSol/DeOps
        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
        }
コード例 #8
0
ファイル: DhtSearch.cs プロジェクト: RoelofSol/DeOps
        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);
        }
コード例 #9
0
ファイル: SearchForm.cs プロジェクト: RoelofSol/DeOps
        public SearchForm(DhtNetwork network)
        {
            InitializeComponent();

            if(network.Core.Sim != null)
                Sim = network.Core.Sim.Internet;

            Network = network;

            Text = "Search (" + Network.GetLabel() + ")";

            OnUpdateList = new UpdateListHandler(UpdateList);
        }
コード例 #10
0
ファイル: VersionedCache.cs プロジェクト: RoelofSol/DeOps
        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;
        }
コード例 #11
0
ファイル: DhtRouting.cs プロジェクト: nandub/DeOps
        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));
        }
コード例 #12
0
ファイル: TempCache.cs プロジェクト: RoelofSol/DeOps
        public TempCache(DhtNetwork network, uint service, uint type)
        {
            Core = network.Core;
            Network = network;

            ServiceID = service;
            DataType = type;

            Core.MinuteTimerEvent += Core_MinuteTimer;

            Network.Store.StoreEvent[ServiceID, DataType] += new StoreHandler(Store_Local);
            Network.Searches.SearchEvent[ServiceID, DataType] += new SearchRequestHandler(Search_Local);

            Network.Store.ReplicateEvent[ServiceID, DataType] += new ReplicateHandler(Store_Replicate);
            Network.Store.PatchEvent[ServiceID, DataType] += new PatchHandler(Store_Patch);
        }
コード例 #13
0
ファイル: GraphForm.cs プロジェクト: RoelofSol/DeOps
        public GraphForm(DhtNetwork network)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            Network = network;
            Core = Network.Core;
            Routing = Network.Routing;

            Network.UpdateBandwidthGraph += AsyncUpdateGraph;

            Text = "Graph (" + Network.GetLabel() + ")";

            Redraw = true;
        }
コード例 #14
0
ファイル: CrawlerForm.cs プロジェクト: RoelofSol/DeOps
        public CrawlerForm(DhtNetwork network)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            Core = network.Core;
            Network = network;
            Routing = Network.Routing;

            Network.CrawlerSearchAck += Receive_SearchAck;
            Network.CrawlerAck  += Receive_CrawlAck;

            Text = "Crawler (" + Network.GetLabel() + ")";

            NodeList.ListViewItemSorter = lvwColumnSorter;
        }
コード例 #15
0
ファイル: IMService.cs プロジェクト: RoelofSol/DeOps
        public IMService(OpCore core)
        {
            Core = core;
            Network = Core.Network;
            Locations = core.Locations;

            Core.SecondTimerEvent += Core_SecondTimer;
            Core.KeepDataCore += new KeepDataHandler(Core_KeepData);

            Network.RudpControl.SessionUpdate += new SessionUpdateHandler(Session_Update);
            Network.RudpControl.SessionData[ServiceID, 0] += new SessionDataHandler(Session_Data);
            Network.RudpControl.KeepActive += new KeepActiveHandler(Session_KeepActive);

            Core.Locations.LocationUpdate += new LocationUpdateHandler(Location_Update);
            Core.Locations.KnowOnline += new KnowOnlineHandler(Location_KnowOnline);

            if (Core.Trust != null)
                Core.Trust.LinkUpdate += new LinkUpdateHandler(Trust_Update);
        }
コード例 #16
0
ファイル: BuddyService.cs プロジェクト: RoelofSol/DeOps
        public BuddyService(OpCore core)
        {
            Core = core;
            Network = Core.Network;
            Core.Buddies = this;

            Network.CoreStatusChange += new StatusChange(Network_StatusChange);
            Core.KeepDataCore += new KeepDataHandler(Core_KeepData);
            Core.Locations.KnowOnline += new KnowOnlineHandler(Location_KnowOnline);
            Core.MinuteTimerEvent += Core_MinuteTimer;
            Cache = new VersionedCache(Network, ServiceID, 0, false);

            Cache.FileAquired += new FileAquiredHandler(Cache_FileAquired);
            Cache.Load();

            if(!BuddyList.SafeContainsKey(Core.UserID))
                AddBuddy(Core.User.Settings.UserName, Core.User.Settings.KeyPublic);

            BuddyList.SafeTryGetValue(Core.UserID, out LocalBuddy);
        }
コード例 #17
0
ファイル: OpCache.cs プロジェクト: swax/DeOps
        public OpCache(DhtNetwork network)
        {
            Core = network.Core;
            Network = network;

            Core.MinuteTimerEvent += Core_MinuteTimerEvent;

            Retry = new RetryIntervals(Core);
            LookupearchInterval = new RetryIntervals(Core);
            NextSave = Core.TimeNow.AddMinutes(1);
            NextPublishAny = Core.TimeNow.AddMinutes(30);

            /*if (Network.IsLookup ||
                (Core.User != null && Core.User.Settings.GlobalIM))
            {
                WebCache cache = new WebCache();
                cache.Address = "http://www.c0re.net/deops/cache/update.php";
                cache.AccessKey = Convert.FromBase64String("O+6IRs7GY1r/JIk+DFY/VK+i8pFTWhsDfNH9R3j3f9Q=");
                AddWebCache(cache);
            }*/
        }
コード例 #18
0
ファイル: LanHandler.cs プロジェクト: RoelofSol/DeOps
        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);
            }
        }
コード例 #19
0
ファイル: DhtStore.cs プロジェクト: RoelofSol/DeOps
 public DhtStore(DhtNetwork network)
 {
     Network = network;
     Core = Network.Core;
 }
コード例 #20
0
ファイル: TcpConnect.cs プロジェクト: RoelofSol/DeOps
        // 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();
            }
        }
コード例 #21
0
ファイル: TcpConnect.cs プロジェクト: RoelofSol/DeOps
        // inbound
        public TcpConnect(TcpHandler control)
        {
            TcpControl = control;
            Network    = TcpControl.Network;
            Core       = TcpControl.Core;

            Bandwidth = new BandwidthLog(Core.RecordBandwidthSeconds);
        }
コード例 #22
0
ファイル: InternalsForm.cs プロジェクト: RoelofSol/DeOps
        public void AddLogs(StructureNode parentNode, DhtNetwork network)
        {
            parentNode.Nodes.Clear();

            lock(network.LogTable)
                foreach (string name in network.LogTable.Keys)
                    parentNode.Nodes.Add( new StructureNode(name, new ShowDelegate(ShowLog), new LogInfo(name, network)));
        }
コード例 #23
0
ファイル: InternetSim.cs プロジェクト: swax/DeOps
 public SimPacket(SimPacketType type, IPEndPoint source, byte[] packet, DhtNetwork dest, TcpConnect tcp, ulong id)
 {
     Type = type;
     Source = source;
     Packet = packet;
     Dest = dest;
     Tcp = tcp;
     SenderID = id;
 }
コード例 #24
0
ファイル: TrustService.cs プロジェクト: RoelofSol/DeOps
        public TrustService(OpCore core)
        {
            Core = core;
            Core.Trust = this;

            Store = Core.Network.Store;
            Network = Core.Network;

            Core.SecondTimerEvent += Core_SecondTimer;
            Core.MinuteTimerEvent += Core_MinuteTimer;
            Core.KeepDataCore += new KeepDataHandler(Core_KeepData);

            Cache = new VersionedCache(Network, ServiceID, DataTypeFile, false);

            Network.CoreStatusChange += new StatusChange(Network_StatusChange);

            // piggyback searching for uplink requests on cache file data
            Store.StoreEvent[ServiceID, DataTypeFile] += new StoreHandler(Store_Local);
            Network.Searches.SearchEvent[ServiceID, DataTypeFile] += new SearchRequestHandler(Search_Local);

            Core.Locations.KnowOnline += new KnowOnlineHandler(Location_KnowOnline);

            Cache.FileAquired += new FileAquiredHandler(Cache_FileAquired);
            Cache.FileRemoved += new FileRemovedHandler(Cache_FileRemoved);
            Cache.Load();

            ProjectNames.SafeAdd(0, Core.User.Settings.Operation);

            LinkPath = Core.User.RootPath + Path.DirectorySeparatorChar + "Data" + Path.DirectorySeparatorChar + ServiceID.ToString();
            Directory.CreateDirectory(LinkPath);

            LocalFileKey = Core.User.Settings.FileKey;

            LoadUplinkReqs();

            LocalTrust = GetTrust(Core.UserID);

            if (LocalTrust == null)
            {
                LocalTrust = new OpTrust(new OpVersionedFile(Core.User.Settings.KeyPublic));
                TrustMap.SafeAdd(Core.UserID, LocalTrust);
            }

            if (!LocalTrust.Loaded)
            {
                LocalTrust.Name = Core.User.Settings.UserName;
                LocalTrust.AddProject(0, true); // operation

                SaveLocal();
            }
        }
コード例 #25
0
 public DhtStore(DhtNetwork network)
 {
     Network = network;
     Core    = Network.Core;
 }
コード例 #26
0
 public DhtSearchControl(DhtNetwork network)
 {
     Network = network;
     Core    = Network.Core;
     Routing = network.Routing;
 }
コード例 #27
0
ファイル: InternalsForm.cs プロジェクト: RoelofSol/DeOps
        public void AddConnectionNodes(StructureNode parentNode, DhtNetwork network)
        {
            parentNode.Nodes.Clear();

            lock(network.TcpControl.SocketList)
                foreach (TcpConnect connect in network.TcpControl.SocketList)
                    parentNode.Nodes.Add( new StructureNode(connect.ToString(), new ShowDelegate(ShowTcpConnect), connect));
        }
コード例 #28
0
ファイル: InternalsForm.cs プロジェクト: RoelofSol/DeOps
        public void LoadNetwork(TreeNodeCollection root, string name, DhtNetwork network)
        {
            StructureNode netItem = new StructureNode(name, new ShowDelegate(ShowNetwork), network);

            // cache
            netItem.Nodes.Add(new StructureNode("Cache", new ShowDelegate(ShowCache), network));

            // logs
            StructureNode logsNode = new StructureNode("Logs", new ShowDelegate(UpdateLogs), network);
            AddLogs(logsNode, network);
            netItem.Nodes.Add(logsNode);

            // routing
            netItem.Nodes.Add(new StructureNode("Routing", new ShowDelegate(ShowRouting), network));

            // search
            StructureNode searchNode = new StructureNode("Searches", new ShowDelegate(ShowNone), null);

            StructureNode pendingNode = new StructureNode("Pending", new ShowDelegate(UpdateSearches), network.Searches.Pending);
            StructureNode activeNode = new StructureNode("Active", new ShowDelegate(UpdateSearches), network.Searches.Active);

            AddSearchNodes(pendingNode, network.Searches.Pending);
            AddSearchNodes(activeNode, network.Searches.Active);

            searchNode.Nodes.Add(pendingNode);
            searchNode.Nodes.Add(activeNode);

            netItem.Nodes.Add(searchNode);

            // store
            StructureNode storeNode = new StructureNode("Store", new ShowDelegate(ShowStore), network);

            netItem.Nodes.Add(storeNode);

            // tcp
            StructureNode connectionsNode = new StructureNode("Tcp", new ShowDelegate(ShowTcp), network);
            AddConnectionNodes(connectionsNode, network);
            netItem.Nodes.Add(connectionsNode);

            // identity
            netItem.Nodes.Add(new StructureNode("Rudp", new ShowDelegate(ShowRudp), network));

            root.Add(netItem);
        }
コード例 #29
0
ファイル: SearchForm.cs プロジェクト: RoelofSol/DeOps
 public static void Show(DhtNetwork network)
 {
     SearchForm form = new SearchForm(network);
     form.Show();
 }
コード例 #30
0
ファイル: OpCore.cs プロジェクト: 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
        }
コード例 #31
0
ファイル: OpCore.cs プロジェクト: swax/DeOps
        // initializing lookup network (from the settings of a loaded operation)
        public OpCore(DeOpsContext context)
        {
            Context = context;
            Sim = context.Sim;

            StartTime = TimeNow;
            GuiProtocol = new G2Protocol();

            Network = new DhtNetwork(this, true);

            // for each core, re-load the lookup cache items
            Context.Cores.LockReading(() =>
            {
                foreach (OpCore core in Context.Cores)
                    core.User.Load(LoadModeType.LookupCache);
            });

            ServiceBandwidth[DhtServiceID] = new BandwidthLog(RecordBandwidthSeconds);

            // get cache from all loaded cores
            AddService(new LookupService(this));

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

            CoreThread = new Thread(RunCore);
            CoreThread.Name = "Lookup Thread";

            if (Sim == null || Sim.Internet.TestCoreThread)
                CoreThread.Start();
        }
コード例 #32
0
ファイル: PacketsForm.cs プロジェクト: RoelofSol/DeOps
        public PacketsForm(DhtNetwork network)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            Network = network;

            Protocol = new G2Protocol();

            Text = "Packets (" + Network.GetLabel() + ")";

            RefreshView();

            Network.UpdatePacketLog += AsyncUpdateLog;
        }
コード例 #33
0
ファイル: RudpHandler.cs プロジェクト: RoelofSol/DeOps
 public RudpHandler(DhtNetwork network)
 {
     Network = network;
 }
コード例 #34
0
ファイル: DhtRouting.cs プロジェクト: nandub/DeOps
        public void Add(DhtContact newContact, bool pong)
        {
            if (Core.User != null && Core.User.Settings.OpAccess == AccessType.Secret)
            {
                Debug.Assert(newContact.TunnelClient == null);
            }

            if (newContact.UserID == 0)
            {
                Network.UpdateLog("Routing", "Zero add attempt");
                return;
            }

            if (newContact.UserID == Network.Local.UserID && newContact.ClientID == Network.Local.ClientID)
            {
                // happens because nodes will include ourselves in returnes to search requests
                //Network.UpdateLog("Routing", "Self add attempt");
                return;
            }

            if (newContact.ClientID == 0)
            {
                return;
            }


            // test to check if non open hosts being added to routing table through simulation
            if (Core.Sim != null && newContact.TunnelClient == null)
            {
                IPEndPoint address = new IPEndPoint(newContact.IP, newContact.UdpPort);

                if (Core.Sim.Internet.UdpEndPoints.ContainsKey(address))
                {
                    DhtNetwork checkNet = Core.Sim.Internet.UdpEndPoints[address];

                    if (checkNet.Local.UserID != newContact.UserID ||
                        checkNet.Local.ClientID != newContact.ClientID ||
                        checkNet.TcpControl.ListenPort != newContact.TcpPort ||
                        checkNet.Core.Sim.RealFirewall != FirewallType.Open)
                    {
                        throw new Exception("Routing add mismatch");
                    }
                }
            }

            // if dht enabled routing entries are set alive by pong
            // many things call add, like the location service, but don't want to falsely report being responsive
            // so only trigger dht responsive when a direct pong comes in
            if (!DhtEnabled || pong)
            {
                newContact.LastSeen = Core.TimeNow;

                if (ContactMap.ContainsKey(newContact.RoutingID))
                {
                    ContactMap[newContact.RoutingID].Alive(Core.TimeNow);
                }

                SetResponsive(true);
            }

            Network.Cache.AddContact(newContact);

            if (ContactMap.ContainsKey(newContact.RoutingID))
            {
                if (!Network.IsLookup)
                {
                    DhtContact dupe = ContactMap[newContact.RoutingID];

                    // tunnel may change from pong / location update etc.. reflect in routing
                    // once host is open and in routing, prevent it from being maliciously set back to tunneled
                    if (dupe.TunnelServer != null)
                    {
                        dupe.TunnelServer = newContact.TunnelServer;
                        dupe.TunnelClient = newContact.TunnelClient;
                    }
                }

                // dont handle dupes
                return;
            }

            // add to searches
            foreach (DhtSearch search in Network.Searches.Active)
            {
                search.Add(newContact);
            }


            AddtoBucket(newContact);

            bool replicate = false;

            // check/set xor bound, cant combine below because both need to run
            if (CheckXor(newContact))
            {
                replicate = true;
            }

            // check if should be added to high/low
            if (CheckHighLow(newContact))
            {
                replicate = true;
            }

            if (replicate)
            {
                Network.Store.Replicate(newContact);
            }

            Core.RunInGuiThread(Network.UpdateBandwidthGraph);
        }
コード例 #35
0
ファイル: InternalsForm.cs プロジェクト: RoelofSol/DeOps
 public LogInfo(string name, DhtNetwork network)
 {
     Name = name;
     Network = network;
 }