Esempio n. 1
0
 public SimpleDHT(IKeyBasedRouter kbr, IMessagingSocket sock, ILocalHashTable lht)
 {
     _kbr = kbr;
     _sock = sock;
     _lht = lht;
     sock.AddInquiredHandler (typeof (GetRequest), MessagingSocket_Inquired_GetRequest);
     sock.AddInquiredHandler (typeof (PutRequest), MessagingSocket_Inquired_PutRequest);
 }
Esempio n. 2
0
 public Node(Interrupters ints, IDatagramEventSocket bindedDgramSock, ITcpListener tcpListener, string db_path, ushort bindUdpPort, ushort bindTcpPort)
 {
     _udpPort = bindUdpPort;
     _tcpPort = bindTcpPort;
     _ints = ints;
     _dgramSock = bindedDgramSock;
     _tcpListener = tcpListener;
     _rtoAlgo = new RFC2988BasedRTOCalculator (TimeSpan.FromSeconds (1), TimeSpan.FromMilliseconds (100), 50, false);
     _messagingSock = new MessagingSocket (_dgramSock, true, SymmetricKey.NoneKey, p2pncs.Serializer.Instance,
         null, ints.MessagingInt, _rtoAlgo, DefaultMessagingRetry, DefaultMessagingRetryBufferSize, DefaultMessagingDuplicationCheckBufferSize);
     _kbrPrivateKey = ECKeyPair.Create (DefaultAlgorithm.ECDomainName);
     _kbr = new SimpleIterativeRouter2 (Key.Create (_kbrPrivateKey), bindTcpPort, _messagingSock, new SimpleRoutingAlgorithm (), p2pncs.Serializer.Instance, true);
     _portChecker = new PortOpenChecker (_kbr);
     _localHT = new OnMemoryLocalHashTable (_kbr, ints.DHTInt);
     IMassKeyDelivererLocalStore mkdLocalStore = _localHT as IMassKeyDelivererLocalStore;
     _dht = new SimpleDHT (_kbr, _messagingSock, _localHT);
     _anonymous = new AnonymousRouter (_dht, _kbrPrivateKey, ints.AnonymousInt);
     ints.KBRStabilizeInt.AddInterruption (Stabilize);
     _mkd = new MassKeyDeliverer (_dht, mkdLocalStore, ints.MassKeyDeliverTimerInt);
     _mmlc = new MMLC (_anonymous, _dht, mkdLocalStore, db_path, ints.StreamSocketTimeoutInt, ints.DFSRePutTimerInt);
     _crawler = new FileInfoCrawler (_tcpListener, _mmlc, _ints.CrawlingTimer);
     _statistics = new Statistics ((AnonymousRouter)_anonymous, _mmlc, _tcpListener);
 }
Esempio n. 3
0
        public VirtualNode(EvalEnvironment env, VirtualNetwork network, EvalOptionSet opt,
			IntervalInterrupter messagingInt, IntervalInterrupter kbrStabilizeInt, IntervalInterrupter anonInt, IntervalInterrupter dhtInt)
        {
            IPAddress pubAdrs = _ipGenerator.Next ();
            int bindPort;
            lock (_rnd) {
                bindPort = _rnd.Next (1024, ushort.MaxValue);
            }
            _pubEP = new IPEndPoint (pubAdrs, bindPort);
            _nodePrivateKey = ECKeyPair.Create (DefaultECDomain);
            _nodeId = Key.Create (_nodePrivateKey);
            VirtualDatagramEventSocket sock = new VirtualDatagramEventSocket (network, pubAdrs);
            sock.Bind (new IPEndPoint (IPAddress.Any, bindPort));
            _msock = opt.BypassMessagingSerializer
                ? (IMessagingSocket)new VirtualMessagingSocket (sock, true, messagingInt, DefaultMessagingRTO, DefaultMessagingRetries, DefaultMessagingRetryBufferSize, DefaultMessagingDupCheckSize)
                : (IMessagingSocket)new MessagingSocket (sock, true, SymmetricKey.NoneKey, Serializer.Instance, null, messagingInt, DefaultMessagingRTO, DefaultMessagingRetries, DefaultMessagingRetryBufferSize, DefaultMessagingDupCheckSize);
            _kbr = new SimpleIterativeRouter2 (_nodeId, 0, _msock, new SimpleRoutingAlgorithm (), Serializer.Instance, opt.NewKBRStrictMode);
            _localDHT = new OnMemoryLocalHashTable (_kbr, dhtInt);
            _dht = new SimpleDHT (_kbr, _msock, _localDHT);
            _dht.RegisterTypeID (typeof (string), 0, new LocalHashTableValueMerger<string> ());
            p2pncs.Net.Overlay.Anonymous.AnonymousRouter.DefaultRelayNodes = opt.AnonymousRouteRelays;
            p2pncs.Net.Overlay.Anonymous.AnonymousRouter.DefaultSubscribeRoutes = opt.AnonymousRouteRoutes + opt.AnonymousRouteBackupRoutes;
            p2pncs.Net.Overlay.Anonymous.AnonymousRouter.AC_DefaultUseSubscribeRoutes = opt.AnonymousRouteRoutes;
            _anonRouter = new AnonymousRouter (_dht, _nodePrivateKey, anonInt);
            _kbrStabilizeInt = kbrStabilizeInt;
            _kbrStabilizeInt.AddInterruption (_kbr.RoutingAlgorithm.Stabilize);
            _env = env;
        }