Inheritance: IRpcHandler
Esempio n. 1
0
 public ApplicationNode(StructuredNode node, IDht dht, RpcDhtProxy dht_proxy,
     NCService ncservice ,ProtocolSecurityOverlord security_overlord)
 {
   Node = node;
   Dht = dht;
   DhtProxy = dht_proxy;
   NCService = ncservice;
   SecurityOverlord = security_overlord;
 }
Esempio n. 2
0
 public ApplicationNode(StructuredNode node, IDht dht, RpcDhtProxy dht_proxy,
     NCService ncservice, SecurityOverlord security_overlord, NodeConfig nc)
 {
   Config = nc;
   Node = node;
   Dht = dht;
   DhtProxy = dht_proxy;
   NCService = ncservice;
   SecurityOverlord = security_overlord;
   SymphonySecurityOverlord = security_overlord as SymphonySecurityOverlord;
 }
Esempio n. 3
0
        /**
         * Constructor.
         * @param n local node
         * @param service local network coordinate service
         */
        public VivaldiTargetSelector(Node n, NCService service)
        {
            _sync             = new object();
            _channel_to_state = new Hashtable();
            _node             = n;
            _nc_service       = service;
            _num_requests     = 0;
#if VTS_DEBUG
            lock (_sync) {
                _node.StateChangeEvent += delegate(Node node, Node.ConnectionState s) {
                    if (s == Node.ConnectionState.Joining)
                    {
                        lock (_class_lock) {
                            _vts_nodes[node] = null;
                            if (_vts_nodes.Keys.Count == 1) //first node
                            {
                                Console.Error.WriteLine("Starting the VTS checkpoint thread. ");
                                _checkpoint_thread          = new Thread(CheckpointThread);
                                _checkpoint_thread_finished = 0;
                                _checkpoint_thread.Start();
                            }
                        }
                    }
                };
                _node.StateChangeEvent += delegate(Node node, Node.ConnectionState s) {
                    if (s == Node.ConnectionState.Disconnected)
                    {
                        lock (_class_lock) {
                            _vts_nodes.Remove(node);
                            if (_vts_nodes.Keys.Count == 0) //last node to leave
                            {
                                Console.Error.WriteLine("Interrupting the VTS checkpoint thread. ");
                                Interlocked.Exchange(ref _checkpoint_thread_finished, 1);
                                _checkpoint_thread.Interrupt();
                                _checkpoint_thread.Join();
                                Console.Error.WriteLine("Join with the VTS checkpoint thread (finished).");
                            }
                        }
                    }
                };
            }
#endif
        }
Esempio n. 4
0
 public NCTunnelOverlap(NCService ncservice)
 {
   _ncservice = ncservice;
 }
Esempio n. 5
0
    public void Test()
    {
      Address addr_x = new AHAddress(new RNGCryptoServiceProvider());
      byte[] addrbuff = Address.ConvertToAddressBuffer(addr_x.ToBigInteger() + (Address.Full / 2));
      Address.SetClass(addrbuff, AHAddress._class);
      Address addr_y = new AHAddress(addrbuff);

      List<Connection> connections = new List<Connection>();
      ConnectionTable ct_x = new ConnectionTable();
      ConnectionTable ct_y = new ConnectionTable();
      ConnectionTable ct_empty = new ConnectionTable();
      NCService ncservice = new NCService();

      Connection fast_con = null;
      for(int i = 1; i <= 11; i++) {
        addrbuff = Address.ConvertToAddressBuffer(addr_x.ToBigInteger() + (i * Address.Full / 16));
        Address.SetClass(addrbuff, AHAddress._class);
        Address addr = new AHAddress(addrbuff);
        Connection con = null;

        TransportAddress ta = TransportAddressFactory.CreateInstance("brunet.tcp://158.7.0.1:5000");
        Edge fe = new FakeEdge(ta, ta, TransportAddress.TAType.Tcp);
        if(i <= 10) {
          con = new Connection(fe, addr, "structured", null, null);
          ct_x.Add(con);
          if(i % 2 == 0) {
            ncservice.ProcessSample(DateTime.UtcNow, String.Empty, addr,
                new Point(new double[] {0, 0}, 0), 0, i*10);
          }
        } else {
          fast_con = new Connection(fe, addr, "structured", null, null);
          ncservice.ProcessSample(DateTime.UtcNow, String.Empty, addr,
              new Point(new double[] {0, 0}, 0), 0, 5);
        }

        if(i == 10) {
          ct_y.Add(con);
        }
        connections.Add(con);
      }

      ITunnelOverlap sto = new SimpleTunnelOverlap();
      ITunnelOverlap nto = new NCTunnelOverlap(ncservice);

      ConnectionType con_type = ConnectionType.Structured;
      List<Connection> pre_cons = new List<Connection>();
      pre_cons.Add(connections[9]);
      IDictionary id = nto.GetSyncMessage(pre_cons, addr_x, ct_x.GetConnections(con_type));

      // We do have some pre-existing overlap
      Assert.AreEqual(nto.EvaluateOverlap(ct_y.GetConnections(con_type), id)[0], connections[9], "NC: Have an overlap!");
      Assert.AreEqual(sto.EvaluateOverlap(ct_y.GetConnections(con_type), id)[0], connections[9], "Simple: Have an overlap!");

      // We have no overlap with an empty connection table
      Assert.AreEqual(nto.EvaluateOverlap(ct_empty.GetConnections(con_type), id).Count, 0, "No overlap!");
      Assert.AreEqual(sto.EvaluateOverlap(ct_empty.GetConnections(con_type), id).Count, 0, "No overlap!");

      // latency[0] == -1
      Assert.AreEqual(connections[1].Address.Equals(nto.EvaluatePotentialOverlap(id)), true,
          "NC: EvaluatePotentialOverlap returns expected!");
      Assert.AreEqual(ct_x.Contains(con_type, sto.EvaluatePotentialOverlap(id)), true,
          "Simple: EvaluatePotentialOverlap returns valid!");

      ct_y.Add(fast_con);
      ct_x.Add(fast_con);
      id = nto.GetSyncMessage(pre_cons, addr_x, ct_x.GetConnections(con_type));
      Assert.AreEqual(fast_con.Address.Equals(nto.EvaluatePotentialOverlap(id)), true,
          "NC: EvaluatePotentialOverlap returns expected!");
      Assert.AreEqual(nto.EvaluateOverlap(ct_y.GetConnections(con_type), id)[0], fast_con, "NC: Have better overlap!");
    }
Esempio n. 6
0
    /// <summary>Creates an ApplicationNode and prepares it for connection to
    /// the overlay.  For historical reasons it is linked to _node, _dht,
    /// _rpc_dht, and _bso.</summary>
    public virtual ApplicationNode CreateNode(NodeConfig node_config) {
      // Get a Node ID for the new Node
      AHAddress address = null;
      try {
        address = (AHAddress) AddressParser.Parse(node_config.NodeAddress);
      } catch {
        address = Utils.GenerateAHAddress();
      }

      // Create the Node state
      StructuredNode node = new StructuredNode(address, node_config.BrunetNamespace);
      _shutdown.OnExit += node.Disconnect;
      IEnumerable addresses = IPAddresses.GetIPAddresses(node_config.DevicesToBind);

      SecurityOverlord so = null;
      // Enable Security if requested
      if(node_config.Security.Enabled) {
        if(node_config.Security.SelfSignedCertificates) {
          SecurityPolicy.SetDefaultSecurityPolicy(SecurityPolicy.DefaultEncryptor,
              SecurityPolicy.DefaultAuthenticator, true);
        }

        byte[] blob = null;
        using(FileStream fs = File.Open(node_config.Security.KeyPath, FileMode.Open)) {
          blob = new byte[fs.Length];
          fs.Read(blob, 0, blob.Length);
        }

        RSACryptoServiceProvider rsa_private = new RSACryptoServiceProvider();
        rsa_private.ImportCspBlob(blob);

        CertificateHandler ch = null;
        if(node_config.Security.Dtls) {
          ch = new OpenSslCertificateHandler(node_config.Security.CertificatePath,
              address.ToString());
        } else {
          ch = new CertificateHandler(node_config.Security.CertificatePath,
              address.ToString());
        }


        if(node_config.Security.SecureEdges) {
          node.EdgeVerifyMethod = EdgeVerify.AddressInSubjectAltName;
        }

        // A hack to enable a test for security that doesn't require each peer
        // to exchange certificates
        if(node_config.Security.TestEnable) {
          blob = rsa_private.ExportCspBlob(false);
          RSACryptoServiceProvider rsa_pub = new RSACryptoServiceProvider();
          rsa_pub.ImportCspBlob(blob);
          CertificateMaker cm = new CertificateMaker("United States", "UFL", 
              "ACIS", "David Wolinsky", "*****@*****.**", rsa_pub,
              "brunet:node:abcdefghijklmnopqrs");
          Certificate cacert = cm.Sign(cm, rsa_private);

          cm = new CertificateMaker("United States", "UFL", 
              "ACIS", "David Wolinsky", "*****@*****.**", rsa_pub,
              address.ToString());
          Certificate cert = cm.Sign(cacert, rsa_private);
          ch.AddCACertificate(cacert.X509);
          ch.AddSignedCertificate(cert.X509);
        }

        if(node_config.Security.Dtls) {
          OpenSslCertificateHandler ssl_ch = ch as OpenSslCertificateHandler;
          so = new DtlsOverlord(rsa_private, ssl_ch, new PType(20));
          node.GetTypeSource(new PType(20)).Subscribe(so, null);
        } else {
          so = new SymphonySecurityOverlord(node, rsa_private, ch, node.Rrm);
          node.GetTypeSource(PeerSecOverlord.Security).Subscribe(so, null);
        }
        so.Subscribe(node, null);
      }

      // Add Dht
      new TableServer(node);
      IDht dht = new Dht(node, 3, 20);
      RpcDhtProxy dht_proxy = new RpcDhtProxy(dht, node);

      // Setup Vivaldi if requested
      IRelayOverlap ito = null;
      NCService ncservice = null;
      if(node_config.NCService.Enabled) {
        ncservice = new NCService(node, node_config.NCService.Checkpoint);

        if (node_config.NCService.OptimizeShortcuts) {
          node.Ssco.TargetSelector = new VivaldiTargetSelector(node, ncservice);
        }
        ito = new NCRelayOverlap(ncservice);
      } else {
        ito = new SimpleRelayOverlap();
      }

      // Create the ApplicationNode
      ApplicationNode app_node = new ApplicationNode(node, dht, dht_proxy, ncservice, so);

      // Add Edge listeners
      EdgeListener el = null;
      foreach(NodeConfig.EdgeListener item in node_config.EdgeListeners) {
        el = CreateEdgeListener(item, app_node, addresses);
        if(node_config.Security.SecureEdgesEnabled) {
          el = new SecureEdgeListener(el, so);
        }
        node.AddEdgeListener(el);
      }

      // Create the tunnel and potentially wrap it in a SecureEL
      el = new Relay.RelayEdgeListener(node, ito);
      if(node_config.Security.SecureEdgesEnabled) {
        el = new SecureEdgeListener(el, so);
      }
      node.AddEdgeListener(el);

      List<TransportAddress> RemoteTAs = null;
      if(node_config.RemoteTAs != null) {
        RemoteTAs = new List<TransportAddress>();
        foreach(String ta in node_config.RemoteTAs) {
          RemoteTAs.Add(TransportAddressFactory.CreateInstance(ta));
        }
        node.RemoteTAs = RemoteTAs;
      }

      // Add XmlRpc
      if(node_config.XmlRpcManager.Enabled) {
        if(_xrm == null) {
          _xrm = new XmlRpcManagerServer(node_config.XmlRpcManager.Port);
        }
        _xrm.Add(node, GetXmlRpcUri(app_node));
        new RpcDht(dht, node);
      }

      if(node_config.PrivateNodeConfig != null &&
          node_config.PrivateNodeConfig.Enabled)
      {
        CreatePrivateNode(app_node, NodeConfig.GetPrivateNodeConfig(node_config));
      }
      return app_node;
    }
Esempio n. 7
0
    /** 
     * Constructor. 
     * @param n local node
     * @param service local network coordinate service
     */
    public VivaldiTargetSelector(Node n, NCService service) {
      _sync = new object();
      _channel_to_state = new Hashtable();
      _node = n;
      _nc_service = service;
      _num_requests = 0;
#if VTS_DEBUG
      lock(_sync) {
        _node.StateChangeEvent += delegate(Node node, Node.ConnectionState s) {
          if( s == Node.ConnectionState.Joining ) {
            lock(_class_lock) {
              _vts_nodes[node] = null;
              if (_vts_nodes.Keys.Count == 1) { //first node
                Console.Error.WriteLine("Starting the VTS checkpoint thread. ");
                _checkpoint_thread = new Thread(CheckpointThread);
                _checkpoint_thread_finished = 0;
                _checkpoint_thread.Start();
              }
            }
          }
        };
        _node.StateChangeEvent += delegate(Node node, Node.ConnectionState s) {
          if( s == Node.ConnectionState.Disconnected ) {
            lock(_class_lock) {
              _vts_nodes.Remove(node);
              if (_vts_nodes.Keys.Count == 0) { //last node to leave
                Console.Error.WriteLine("Interrupting the VTS checkpoint thread. ");
                Interlocked.Exchange(ref _checkpoint_thread_finished, 1);
                _checkpoint_thread.Interrupt();
                _checkpoint_thread.Join();
                Console.Error.WriteLine("Join with the VTS checkpoint thread (finished).");
              }
            }
          }
        };
      }
#endif
    }
Esempio n. 8
0
    public void TestSerialize() {
      NCService nc_service = new NCService();
      Hashtable ht1 = nc_service.EchoVivaldiState();
      MemoryStream ms = new MemoryStream();
      int serialized = AdrConverter.Serialize(ht1, ms);
      byte[] buf = ms.ToArray();
      Assert.AreEqual(serialized, buf.Length, "Buffer length same as written");
      ms.Seek(0, SeekOrigin.Begin);
      object o = AdrConverter.Deserialize(ms);
      Hashtable ht =  o as Hashtable;
      Assert.IsTrue(ht != null);
      Hashtable ht_position = (Hashtable) ht["position"];
      Point o_position = 
  new Point((double[]) ((ArrayList) ht_position["side"]).ToArray(typeof(double)), (double) ht_position["height"]);
    
      double o_weightedError = (double) ht["error"];
      // 
      // Make sure that the values obtained match the orgininal NC state.
      //

      NCService.VivaldiState state = nc_service.State;

      Assert.IsTrue(o_position.Equals(state.Position));
      Assert.AreEqual(o_weightedError, state.WeightedError);
    }
Esempio n. 9
0
    public void TestService() {
      NCService nc_service = new NCService();
      DateTime now = DateTime.UtcNow;
      Address addr_remote = new AHAddress(new RNGCryptoServiceProvider());
      Address addr_remote1 = new AHAddress(new RNGCryptoServiceProvider());
      Address addr_remote2 = new AHAddress(new RNGCryptoServiceProvider());

      nc_service.ProcessSample(now + new TimeSpan(0, 0, 5), "local-test", addr_remote, 
             new Point(new double[] {(double) 3.0, (double) 4.0}, 0),
             (double) 0.9, (double)10.0); 
      NCService.VivaldiState state = nc_service.State;
      

      nc_service.ProcessSample(now + new TimeSpan(0, 0, 6), "local-test",addr_remote1, 
             new Point(new double[] {(double) 10.0, (double) 2.0}, 0),
             (double) 0.9, (double)10.0); 

      nc_service.ProcessSample(now + new TimeSpan(0, 0, 6), "local-test",addr_remote2, 
             new Point(new double[] {(double) 5.0, (double) 6.0}, 0),
             (double) 0.9, (double)10.0); 


      nc_service.ProcessSample(now + new TimeSpan(0, 0, 7), "local-test",addr_remote, 
             new Point(new double[] {(double) 3.0, (double) 4.0}, 0),
             (double) 0.8, (double)12.0); 

      nc_service.ProcessSample(now + new TimeSpan(0, 0, 8), "local-test",addr_remote1, 
             new Point(new double[] {(double) 10.0, (double) 2.0}, 0),
             (double) 0.8, (double)12.0); 


      nc_service.ProcessSample(now + new TimeSpan(0, 0, 9), "local-test",addr_remote, 
             new Point(new double[] {(double) 3.0, (double) 4.0}, 0),
             (double)0.7, (double)13.0); 

      nc_service.ProcessSample(now + new TimeSpan(0, 0, 11), "local-test",addr_remote1, 
             new Point(new double[] {(double) 10.0, (double) 2.0}, 0),
             (double)0.7, (double)13.0); 


      nc_service.ProcessSample(now + new TimeSpan(0, 0, 12), "local-test",addr_remote, 
             new Point(new double[] {(double) 3.0, (double) 4.0}, 0),
             (double)0.6, (double)10.0); 

      nc_service.ProcessSample(now + new TimeSpan(0, 0, 13), "local-test",addr_remote1, 
             new Point(new double[] {(double) 10.0, (double) 2.0}, 0),
             (double)0.6, (double)10.0);       

      state = nc_service.State;
      Console.Error.WriteLine("position: {0}, error: {1}", state.Position, state.WeightedError);
    }
Esempio n. 10
0
 public NCRelayOverlap(NCService ncservice)
 {
     _ncservice = ncservice;
 }
Esempio n. 11
0
        public void Test()
        {
            Address addr_x = new AHAddress(new RNGCryptoServiceProvider());

            byte[] addrbuff = Address.ConvertToAddressBuffer(addr_x.ToBigInteger() + (Address.Full / 2));
            Address.SetClass(addrbuff, AHAddress._class);
            Address addr_y = new AHAddress(addrbuff);

            List <Connection> connections = new List <Connection>();
            ConnectionTable   ct_x        = new ConnectionTable();
            ConnectionTable   ct_y        = new ConnectionTable();
            ConnectionTable   ct_empty    = new ConnectionTable();
            NCService         ncservice   = new NCService();

            Connection fast_con = null;

            for (int i = 1; i <= 11; i++)
            {
                addrbuff = Address.ConvertToAddressBuffer(addr_x.ToBigInteger() + (i * Address.Full / 16));
                Address.SetClass(addrbuff, AHAddress._class);
                Address    addr = new AHAddress(addrbuff);
                Connection con  = null;

                TransportAddress ta = TransportAddressFactory.CreateInstance("brunet.tcp://158.7.0.1:5000");
                Edge             fe = new FakeEdge(ta, ta, TransportAddress.TAType.Tcp);
                if (i <= 10)
                {
                    con = new Connection(fe, addr, "structured", null, null);
                    ct_x.Add(con);
                    if (i % 2 == 0)
                    {
                        ncservice.ProcessSample(DateTime.UtcNow, String.Empty, addr,
                                                new Point(new double[] { 0, 0 }, 0), 0, i * 10);
                    }
                }
                else
                {
                    fast_con = new Connection(fe, addr, "structured", null, null);
                    ncservice.ProcessSample(DateTime.UtcNow, String.Empty, addr,
                                            new Point(new double[] { 0, 0 }, 0), 0, 5);
                }

                if (i == 10)
                {
                    ct_y.Add(con);
                }
                connections.Add(con);
            }

            IRelayOverlap sto = new SimpleRelayOverlap();
            IRelayOverlap nto = new NCRelayOverlap(ncservice);

            ConnectionType    con_type = ConnectionType.Structured;
            List <Connection> pre_cons = new List <Connection>();

            pre_cons.Add(connections[9]);
            IDictionary id = nto.GetSyncMessage(pre_cons, addr_x, ct_x.GetConnections(con_type));

            // We do have some pre-existing overlap
            Assert.AreEqual(nto.EvaluateOverlap(ct_y.GetConnections(con_type), id)[0], connections[9], "NC: Have an overlap!");
            Assert.AreEqual(sto.EvaluateOverlap(ct_y.GetConnections(con_type), id)[0], connections[9], "Simple: Have an overlap!");

            // We have no overlap with an empty connection table
            Assert.AreEqual(nto.EvaluateOverlap(ct_empty.GetConnections(con_type), id).Count, 0, "No overlap!");
            Assert.AreEqual(sto.EvaluateOverlap(ct_empty.GetConnections(con_type), id).Count, 0, "No overlap!");

            // latency[0] == -1
            Assert.AreEqual(connections[1].Address.Equals(nto.EvaluatePotentialOverlap(id)), true,
                            "NC: EvaluatePotentialOverlap returns expected!");
            Assert.AreEqual(ct_x.Contains(con_type, sto.EvaluatePotentialOverlap(id)), true,
                            "Simple: EvaluatePotentialOverlap returns valid!");

            ct_y.Add(fast_con);
            ct_x.Add(fast_con);
            id = nto.GetSyncMessage(pre_cons, addr_x, ct_x.GetConnections(con_type));
            Assert.AreEqual(fast_con.Address.Equals(nto.EvaluatePotentialOverlap(id)), true,
                            "NC: EvaluatePotentialOverlap returns expected!");
            Assert.AreEqual(nto.EvaluateOverlap(ct_y.GetConnections(con_type), id)[0], fast_con, "NC: Have better overlap!");
        }
Esempio n. 12
0
    /// <summary>Creates a Brunet.Node, the resulting node will be available in
    /// the class as _node.</summary>
    /// <remarks>The steps to creating a node are first constructing it with a
    /// namespace, optionally adding local ip addresses to bind to, specifying
    /// local end points, specifying remote end points, and finally registering
    /// the dht.</remarks>
    public virtual void CreateNode() {
      AHAddress address = null;
      try {
        address = (AHAddress) AddressParser.Parse(_node_config.NodeAddress);
      } catch {
        address = Utils.GenerateAHAddress();
      }

      _node = new StructuredNode(address, _node_config.BrunetNamespace);
      IEnumerable addresses = IPAddresses.GetIPAddresses(_node_config.DevicesToBind);

      if(_node_config.Security.Enabled) {
        if(_node_config.Security.SelfSignedCertificates) {
          SecurityPolicy.SetDefaultSecurityPolicy(SecurityPolicy.DefaultEncryptor,
              SecurityPolicy.DefaultAuthenticator, true);
        }

        byte[] blob = null;
        using(FileStream fs = File.Open(_node_config.Security.KeyPath, FileMode.Open)) {
          blob = new byte[fs.Length];
          fs.Read(blob, 0, blob.Length);
        }

        RSACryptoServiceProvider rsa_private = new RSACryptoServiceProvider();
        rsa_private.ImportCspBlob(blob);

        CertificateHandler ch = new CertificateHandler(_node_config.Security.CertificatePath);
        _bso = new ProtocolSecurityOverlord(_node, rsa_private, _node.Rrm, ch);
        _bso.Subscribe(_node, null);

        _node.GetTypeSource(SecurityOverlord.Security).Subscribe(_bso, null);
        _node.HeartBeatEvent += _bso.Heartbeat;

        if(_node_config.Security.TestEnable) {
          blob = rsa_private.ExportCspBlob(false);
          RSACryptoServiceProvider rsa_pub = new RSACryptoServiceProvider();
          rsa_pub.ImportCspBlob(blob);
          CertificateMaker cm = new CertificateMaker("United States", "UFL", 
              "ACIS", "David Wolinsky", "*****@*****.**", rsa_pub,
              "brunet:node:abcdefghijklmnopqrs");
          Certificate cacert = cm.Sign(cm, rsa_private);

          cm = new CertificateMaker("United States", "UFL", 
              "ACIS", "David Wolinsky", "*****@*****.**", rsa_pub,
              address.ToString());
          Certificate cert = cm.Sign(cacert, rsa_private);
          ch.AddCACertificate(cacert.X509);
          ch.AddSignedCertificate(cert.X509);
        }
      }

      EdgeListener el = null;
      foreach(NodeConfig.EdgeListener item in _node_config.EdgeListeners) {
        int port = item.port;
        if(item.type == "tcp") {
          try {
            el = new TcpEdgeListener(port, addresses);
          }
          catch {
            el = new TcpEdgeListener(0, addresses);
          }
        } else if(item.type == "udp") {
          try {
            el = new UdpEdgeListener(port, addresses);
          }
          catch {
            el = new UdpEdgeListener(0, addresses);
          }
        } else if(item.type == "function") {
          port = port == 0 ? (new Random()).Next(1024, 65535) : port;
          el = new FunctionEdgeListener(port, 0, null);
        } else {
          throw new Exception("Unrecognized transport: " + item.type);
        }
        if(_node_config.Security.SecureEdgesEnabled) {
          el = new SecureEdgeListener(el, _bso);
        }
        _node.AddEdgeListener(el);
      }

      ArrayList RemoteTAs = null;
      if(_node_config.RemoteTAs != null) {
        RemoteTAs = new ArrayList();
        foreach(String ta in _node_config.RemoteTAs) {
          RemoteTAs.Add(TransportAddressFactory.CreateInstance(ta));
        }
        _node.RemoteTAs = RemoteTAs;
      }

      ITunnelOverlap ito = null;
      if(_node_config.NCService.Enabled) {
        _ncservice = new NCService(_node, _node_config.NCService.Checkpoint);

        if (_node_config.NCService.OptimizeShortcuts) {
          _node.Ssco.TargetSelector = new VivaldiTargetSelector(_node, _ncservice);
        }
        ito = new NCTunnelOverlap(_ncservice);
      } else {
        ito = new SimpleTunnelOverlap();
      }

      el = new Tunnel.TunnelEdgeListener(_node, ito);
      if(_node_config.Security.SecureEdgesEnabled) {
        _node.EdgeVerifyMethod = EdgeVerify.AddressInSubjectAltName;
        el = new SecureEdgeListener(el, _bso);
      }
      _node.AddEdgeListener(el);


      new TableServer(_node);
      _dht = new Dht(_node, 3, 20);
      _dht_proxy = new RpcDhtProxy(_dht, _node);
    }
Esempio n. 13
0
 public NCRelayOverlap(NCService ncservice)
 {
   _ncservice = ncservice;
 }
Esempio n. 14
0
    /**
    <summary>This should be called by the Main after all the setup is done
    this passes control to the _node and won't return until the program is
    exiting.  (It is synchronous.)</summary>
    */
    public virtual void Run() {
      int sleep = 60, sleep_min = 60, sleep_max = 3600;
      DateTime start_time = DateTime.UtcNow;
      // Keep creating new nodes no matter what!
      while(_running) {
        //NCService is default function for cache ring(cache node)
        CreateNode("cache");
        CreateNode("query");
      	//ncservice = new NCService(_c_node, _q_node, _c_node_config.NCService.Checkpoint);
      	_ncservice = new NCService(_c_node, _q_node);
        new Information(_c_node, "CacheNode");
        new Information(_q_node, "QueryNode");
        Console.WriteLine("CacheNode is connected to {0} as {1}.  Current time is {2}.",
                                _c_node.Realm, _c_node.Address.ToString(), DateTime.UtcNow);
        Console.WriteLine("QueryNode is connected to {0} as {1}.  Current time is {2}.",
                                _q_node.Realm, _q_node.Address.ToString(), DateTime.UtcNow);
        _c_node.DisconnectOnOverload = true;
        _q_node.DisconnectOnOverload = true;
        start_time = DateTime.UtcNow;
        StartServices();
        Thread c_thread = new Thread(_c_node.Connect );
        c_thread.Start();
        _q_node.Connect(); //stop
        c_thread.Join();
        SuspendServices();
        if(!_running) {
          break;
        }
	Console.WriteLine("start node running9");
        // Assist in garbage collection
        DateTime now = DateTime.UtcNow;
        Console.WriteLine("Going to sleep for {0} seconds. Current time is: {1}", sleep, now);
        Thread.Sleep(sleep * 1000);
        if(now - start_time < TimeSpan.FromSeconds(sleep_max)) {
          sleep *= 2;
          sleep = (sleep > sleep_max) ? sleep_max : sleep;
        }
        else {
          sleep /= 2;
          sleep = (sleep < sleep_min) ? sleep_min : sleep;
        }
      }
    }
Esempio n. 15
0
 public NCTunnelOverlap(NCService ncservice)
 {
     _ncservice = ncservice;
 }