public ConnectionHandler(PType ptype, StructuredNode node) { _node = node; _ondemand = new OnDemandConnectionOverlord(node); _node.AddConnectionOverlord(_ondemand); _ptype = ptype; _ptype_mb = ptype.ToMemBlock(); _address_to_sender = new Dictionary <Address, ISender>(); _sender_to_address = new Dictionary <ISender, Address>(); _con_to_csw = new Dictionary <Connection, ConSenderWrapper>(); node.GetTypeSource(_ptype).Subscribe(this, null); node.ConnectionTable.ConnectionEvent += HandleConnection; node.ConnectionTable.DisconnectionEvent += HandleDisconnection; }
protected virtual StructuredNode PrepareNode(int id, AHAddress address) { if (TakenIDs.ContainsKey(id)) { throw new Exception("ID already taken"); } StructuredNode node = new StructuredNode(address, BrunetNamespace); NodeMapping nm = new NodeMapping(); nm.ID = id; TakenIDs[id] = nm; nm.Node = node; Nodes.Add((Address)address, nm); EdgeListener el = CreateEdgeListener(nm.ID); if (_secure_edges || _secure_senders) { byte[] blob = _se_key.ExportCspBlob(true); RSACryptoServiceProvider rsa_copy = new RSACryptoServiceProvider(); rsa_copy.ImportCspBlob(blob); string username = address.ToString().Replace('=', '0'); CertificateMaker cm = new CertificateMaker("United States", "UFL", "ACIS", username, "*****@*****.**", rsa_copy, address.ToString()); Certificate cert = cm.Sign(_ca_cert, _se_key); CertificateHandler ch = null; if (_dtls) { ch = new OpenSslCertificateHandler(); } else { ch = new CertificateHandler(); } ch.AddCACertificate(_ca_cert.X509); ch.AddSignedCertificate(cert.X509); if (_dtls) { nm.SO = new DtlsOverlord(rsa_copy, ch, PeerSecOverlord.Security); } else { nm.Sso = new SymphonySecurityOverlord(node, rsa_copy, ch, node.Rrm); nm.SO = nm.Sso; } var brh = new BroadcastRevocationHandler(_ca_cert, nm.SO); node.GetTypeSource(BroadcastRevocationHandler.PType).Subscribe(brh, null); ch.AddCertificateVerification(brh); nm.SO.Subscribe(node, null); node.GetTypeSource(PeerSecOverlord.Security).Subscribe(nm.SO, null); } if (_pathing) { nm.PathEM = new PathELManager(el, nm.Node); nm.PathEM.Start(); el = nm.PathEM.CreatePath(); PType path_p = PType.Protocol.Pathing; nm.Node.DemuxHandler.GetTypeSource(path_p).Subscribe(nm.PathEM, path_p); } if (_secure_edges) { node.EdgeVerifyMethod = EdgeVerify.AddressInSubjectAltName; el = new SecureEdgeListener(el, nm.SO); } node.AddEdgeListener(el); if (!_start) { node.RemoteTAs = GetRemoteTAs(); } IRelayOverlap ito = null; if (NCEnable) { nm.NCService = new NCService(node, new Point()); // My evaluations show that when this is enabled the system sucks // (node as StructuredNode).Sco.TargetSelector = new VivaldiTargetSelector(node, ncservice); ito = new NCRelayOverlap(nm.NCService); } else { ito = new SimpleRelayOverlap(); } if (_broken != 0) { el = new Relay.RelayEdgeListener(node, ito); if (_secure_edges) { el = new SecureEdgeListener(el, nm.SO); } node.AddEdgeListener(el); } BroadcastHandler bhandler = new BroadcastHandler(node as StructuredNode); node.DemuxHandler.GetTypeSource(BroadcastSender.PType).Subscribe(bhandler, null); node.DemuxHandler.GetTypeSource(SimBroadcastPType).Subscribe(SimBroadcastHandler, null); // Enables Dht data store new TableServer(node); nm.Dht = new Dht(node, 3, 20); nm.DhtProxy = new RpcDhtProxy(nm.Dht, node); return(node); }
/// <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; }
public static void Main(string []args) { if (args.Length < 1) { Console.WriteLine("please specify the number edge protocol."); Environment.Exit(0); } if (args.Length < 2) { Console.WriteLine("please specify the number of p2p nodes."); Environment.Exit(0); } if (args.Length < 3) { Console.WriteLine("please specify the number of missing edges."); Environment.Exit(0); } string proto = "function"; try { proto = args[0].Trim(); } catch(Exception) {} bool tunnel = false; int base_port = 54000; int network_size = Int32.Parse(args[1]); int missing_count = Int32.Parse(args[2]); try { tunnel = args[3].Trim().Equals("tunnel"); } catch (Exception) {} Console.WriteLine("use tunnel edges: {0}", tunnel); Random rand = new Random(); ArrayList missing_edges = new ArrayList(); for (int i = 0; i < missing_count; i++) { int idx = -1; int left, right; do { idx = rand.Next(0, network_size); left = (idx + 1)%network_size; if (idx == 0) { right = network_size - 1; } else { right = idx - 1; } } while (missing_edges.Contains(idx));// || //missing_edges.Contains(left) || //missing_edges.Contains(right)); Console.WriteLine("Will drop a left edge on idx {0}: ", idx); missing_edges.Add(idx); } // // Sort missing edges. // missing_edges.Sort(); SortedList dist = new SortedList(); // // Compute the average distance between missing edges. // if (missing_count > 1) { for (int i = 0; i < missing_count; i++) { int idx = (int) missing_edges[i]; int idx_next; int d; if (i == missing_count - 1) { idx_next = (int) missing_edges[0]; d = (network_size - 1) - idx + idx_next; } else { idx_next = (int) missing_edges[i+1]; d = idx_next - idx - 1; } if (!dist.Contains(d)) { dist[d] = 0; } else { int c = (int) dist[d]; dist[d] = c + 1; } } } double sum = 0.0; int num = 0; Console.WriteLine("distribution of missing edges separation"); foreach(DictionaryEntry de in dist) { int k = (int) de.Key; int c = (int) de.Value; Console.WriteLine("{0} {1}", k, c); sum = sum + k*c; num = num + c; } Console.WriteLine("average separation: {0}", (double) sum/num); string brunet_namespace = "testing"; Console.WriteLine("Initializing..."); ArrayList RemoteTA = new ArrayList(); for(int i = 0; i < network_size; i++) { if (proto.Equals("udp")) { RemoteTA.Add(TransportAddressFactory.CreateInstance("brunet.udp://localhost:" + (base_port + i))); } else if (proto.Equals("function")) { RemoteTA.Add(TransportAddressFactory.CreateInstance("brunet.function://localhost:" + (base_port + i))); } } for(int i = 0; i < network_size; i++) { AHAddress address = new AHAddress(new RNGCryptoServiceProvider()); Node node = new StructuredNode(address, brunet_namespace); _sorted_node_list.Add((Address) address, node); _node_list.Add(node); RouteTestHandler test_handler = new RouteTestHandler(); node.GetTypeSource(new PType(routing_test)).Subscribe(test_handler, address.ToMemBlock()); RpcManager rpc_man = node.Rpc; rpc_man.AddHandler("rpc_routing_test", new RpcRoutingTestHandler(node)); } for (int i = 0; i < network_size; i++) { Node node = (Node) _sorted_node_list.GetByIndex(i); Console.WriteLine("Configuring node: {0} ", node.Address); TAAuthorizer ta_auth = null; if (missing_edges.Contains(i)) { int remote_port; if (i == network_size - 1) { remote_port = base_port; } else { remote_port = base_port + i + 1; } PortTAAuthorizer port_auth = new PortTAAuthorizer(remote_port); Console.WriteLine("Adding a port TA authorizer at: {0} for remote port: {1}", base_port + i, remote_port); ArrayList arr_tas = new ArrayList(); arr_tas.Add(port_auth); arr_tas.Add(new ConstantAuthorizer(TAAuthorizer.Decision.Allow)); ta_auth = new SeriesTAAuthorizer(arr_tas); } if (proto.Equals("udp")) { node.AddEdgeListener(new UdpEdgeListener(base_port + i, null, ta_auth)); } else if(proto.Equals("function")) { node.AddEdgeListener(new FunctionEdgeListener(base_port + i, -1.00, ta_auth)); } if (tunnel) { Console.WriteLine("Adding a tunnel edge listener"); node.AddEdgeListener(new Tunnel.TunnelEdgeListener(node)); } _node_to_port[node] = base_port + i; node.RemoteTAs = RemoteTA; } //start nodes one by one. for (int i = 0; i < network_size; i++) { Node node = (Node) _node_list[i]; Console.WriteLine("Starting node: {0}, {1}", i, node.Address); node.Connect(); Console.WriteLine("Going to sleep for 2 seconds."); System.Threading.Thread.Sleep(2000); } //wait for 300000 more seconds Console.WriteLine("Going to sleep for 300000 seconds."); System.Threading.Thread.Sleep(300000); bool complete = CheckStatus(); int count = 0; // // Send a large number of packets as exact packets to random destinations // and make sure exact routing is perfect. // for (int i = 0; i < network_size; i++) { for (int j = 0; j < network_size; j++) { int src_idx = i; int dest_idx = j; Node src_node = (Node) _sorted_node_list.GetByIndex(src_idx); Node dest_node = (Node) _sorted_node_list.GetByIndex(dest_idx); //Console.WriteLine("{0} -> {1}", src_idx, dest_idx); Address dest_address = (Address) dest_node.Address; ISender s = new AHExactSender(src_node, dest_address); MemBlock p = dest_address.ToMemBlock(); s.Send(new CopyList(new PType(routing_test), p)); _sent++; //System.Threading.Thread.Sleep(10); s.Send(new CopyList(new PType(routing_test), p)); _sent++; //System.Threading.Thread.Sleep(10); } } //wait for 10 more seconds Console.WriteLine("Going to sleep for 10 seconds."); System.Threading.Thread.Sleep(10000); Console.WriteLine("Final statistics"); lock(_class_lock) { Console.WriteLine("Sent: {0}, Received: {1}, Wrongly routed: {2}", _sent, _received, _wrongly_routed); } int missing_rpcs = 0; int correct_rpcs = 0; int incorrect_rpcs = 0; Hashtable queue_to_address = new Hashtable(); for (int i = 0; i < network_size; i++) { for (int j = 0; j < network_size; j++) { int src_idx = i; int dest_idx = j; Node src_node = (Node) _sorted_node_list.GetByIndex(src_idx); Node dest_node = (Node) _sorted_node_list.GetByIndex(dest_idx); //Console.WriteLine("{0} -> {1}", src_idx, dest_idx); Address dest_address = (Address) dest_node.Address; ISender s = new AHExactSender(src_node, dest_address); RpcManager rpc_man = src_node.Rpc; Channel q = new Channel(); lock (_class_lock) { queue_to_address[q] = dest_address; } q.CloseAfterEnqueue(); q.CloseEvent += delegate(object o, EventArgs cargs) { lock(_class_lock) { Channel qu = (Channel) o; if (qu.Count == 0) { missing_rpcs++; } queue_to_address.Remove(qu); } }; q.EnqueueEvent += delegate(object o, EventArgs cargs) { lock(_class_lock) { Channel qu = (Channel) o; RpcResult rpc_reply = (RpcResult) qu.Peek(); byte []result = (byte[]) rpc_reply.Result; Address target = new AHAddress(result); if (target.Equals(queue_to_address[qu])) { correct_rpcs++; } else { incorrect_rpcs++; } } }; rpc_man.Invoke(s, q, "rpc_routing_test.GetIdentification", new object[]{}); } } //wait for 10 more seconds while (true) { int c = -1; lock(_class_lock) { c = incorrect_rpcs + missing_rpcs + correct_rpcs; } if (c < network_size*network_size) { Console.WriteLine("Going to sleep for 10 seconds."); System.Threading.Thread.Sleep(10000); } else { break; } } Console.WriteLine("Final statistics"); Console.WriteLine("correct rpcs: {0}, incorrect rpcs: {1}, missing rpcs: {2}", correct_rpcs, incorrect_rpcs, missing_rpcs); System.Environment.Exit(1); }
public static void Main(string [] args) { if (args.Length < 1) { Console.WriteLine("please specify the number edge protocol."); Environment.Exit(0); } if (args.Length < 2) { Console.WriteLine("please specify the number of p2p nodes."); Environment.Exit(0); } if (args.Length < 3) { Console.WriteLine("please specify the number of missing edges."); Environment.Exit(0); } string proto = "function"; try { proto = args[0].Trim(); } catch (Exception) {} bool tunnel = false; int base_port = 54000; int network_size = Int32.Parse(args[1]); int missing_count = Int32.Parse(args[2]); try { tunnel = args[3].Trim().Equals("tunnel"); } catch (Exception) {} Console.WriteLine("use tunnel edges: {0}", tunnel); Random rand = new Random(); ArrayList missing_edges = new ArrayList(); for (int i = 0; i < missing_count; i++) { int idx = -1; int left, right; do { idx = rand.Next(0, network_size); left = (idx + 1) % network_size; if (idx == 0) { right = network_size - 1; } else { right = idx - 1; } } while (missing_edges.Contains(idx));// || //missing_edges.Contains(left) || //missing_edges.Contains(right)); Console.WriteLine("Will drop a left edge on idx {0}: ", idx); missing_edges.Add(idx); } // // Sort missing edges. // missing_edges.Sort(); SortedList dist = new SortedList(); // // Compute the average distance between missing edges. // if (missing_count > 1) { for (int i = 0; i < missing_count; i++) { int idx = (int)missing_edges[i]; int idx_next; int d; if (i == missing_count - 1) { idx_next = (int)missing_edges[0]; d = (network_size - 1) - idx + idx_next; } else { idx_next = (int)missing_edges[i + 1]; d = idx_next - idx - 1; } if (!dist.Contains(d)) { dist[d] = 0; } else { int c = (int)dist[d]; dist[d] = c + 1; } } } double sum = 0.0; int num = 0; Console.WriteLine("distribution of missing edges separation"); foreach (DictionaryEntry de in dist) { int k = (int)de.Key; int c = (int)de.Value; Console.WriteLine("{0} {1}", k, c); sum = sum + k * c; num = num + c; } Console.WriteLine("average separation: {0}", (double)sum / num); string brunet_namespace = "testing"; Console.WriteLine("Initializing..."); var RemoteTA = new List <TransportAddress>(); for (int i = 0; i < network_size; i++) { if (proto.Equals("udp")) { RemoteTA.Add(TransportAddressFactory.CreateInstance("brunet.udp://localhost:" + (base_port + i))); } else if (proto.Equals("function")) { RemoteTA.Add(TransportAddressFactory.CreateInstance("brunet.function://localhost:" + (base_port + i))); } } for (int i = 0; i < network_size; i++) { AHAddress address = new AHAddress(new RNGCryptoServiceProvider()); Node node = new StructuredNode(address, brunet_namespace); _sorted_node_list.Add((Address)address, node); _node_list.Add(node); RouteTestHandler test_handler = new RouteTestHandler(); node.GetTypeSource(new PType(routing_test)).Subscribe(test_handler, address.ToMemBlock()); RpcManager rpc_man = node.Rpc; rpc_man.AddHandler("rpc_routing_test", new RpcRoutingTestHandler(node)); } for (int i = 0; i < network_size; i++) { Node node = (Node)_sorted_node_list.GetByIndex(i); Console.WriteLine("Configuring node: {0} ", node.Address); TAAuthorizer ta_auth = null; if (missing_edges.Contains(i)) { int remote_port; if (i == network_size - 1) { remote_port = base_port; } else { remote_port = base_port + i + 1; } PortTAAuthorizer port_auth = new PortTAAuthorizer(remote_port); Console.WriteLine("Adding a port TA authorizer at: {0} for remote port: {1}", base_port + i, remote_port); ArrayList arr_tas = new ArrayList(); arr_tas.Add(port_auth); arr_tas.Add(new ConstantAuthorizer(TAAuthorizer.Decision.Allow)); ta_auth = new SeriesTAAuthorizer(arr_tas); } if (proto.Equals("udp")) { node.AddEdgeListener(new UdpEdgeListener(base_port + i, null, ta_auth)); } else if (proto.Equals("function")) { node.AddEdgeListener(new FunctionEdgeListener(base_port + i, -1.00, ta_auth)); } if (tunnel) { Console.WriteLine("Adding a tunnel edge listener"); node.AddEdgeListener(new Relay.RelayEdgeListener(node)); } _node_to_port[node] = base_port + i; node.RemoteTAs = RemoteTA; } //start nodes one by one. for (int i = 0; i < network_size; i++) { Node node = (Node)_node_list[i]; Console.WriteLine("Starting node: {0}, {1}", i, node.Address); node.Connect(); Console.WriteLine("Going to sleep for 2 seconds."); System.Threading.Thread.Sleep(2000); } //wait for 300000 more seconds Console.WriteLine("Going to sleep for 300000 seconds."); System.Threading.Thread.Sleep(300000); bool complete = CheckStatus(); int count = 0; // // Send a large number of packets as exact packets to random destinations // and make sure exact routing is perfect. // for (int i = 0; i < network_size; i++) { for (int j = 0; j < network_size; j++) { int src_idx = i; int dest_idx = j; Node src_node = (Node)_sorted_node_list.GetByIndex(src_idx); Node dest_node = (Node)_sorted_node_list.GetByIndex(dest_idx); //Console.WriteLine("{0} -> {1}", src_idx, dest_idx); Address dest_address = (Address)dest_node.Address; ISender s = new AHExactSender(src_node, dest_address); MemBlock p = dest_address.ToMemBlock(); s.Send(new CopyList(new PType(routing_test), p)); _sent++; //System.Threading.Thread.Sleep(10); s.Send(new CopyList(new PType(routing_test), p)); _sent++; //System.Threading.Thread.Sleep(10); } } //wait for 10 more seconds Console.WriteLine("Going to sleep for 10 seconds."); System.Threading.Thread.Sleep(10000); Console.WriteLine("Final statistics"); lock (_class_lock) { Console.WriteLine("Sent: {0}, Received: {1}, Wrongly routed: {2}", _sent, _received, _wrongly_routed); } int missing_rpcs = 0; int correct_rpcs = 0; int incorrect_rpcs = 0; Hashtable queue_to_address = new Hashtable(); for (int i = 0; i < network_size; i++) { for (int j = 0; j < network_size; j++) { int src_idx = i; int dest_idx = j; Node src_node = (Node)_sorted_node_list.GetByIndex(src_idx); Node dest_node = (Node)_sorted_node_list.GetByIndex(dest_idx); //Console.WriteLine("{0} -> {1}", src_idx, dest_idx); Address dest_address = (Address)dest_node.Address; ISender s = new AHExactSender(src_node, dest_address); RpcManager rpc_man = src_node.Rpc; Channel q = new Channel(); lock (_class_lock) { queue_to_address[q] = dest_address; } q.CloseAfterEnqueue(); q.CloseEvent += delegate(object o, EventArgs cargs) { lock (_class_lock) { Channel qu = (Channel)o; if (qu.Count == 0) { missing_rpcs++; } queue_to_address.Remove(qu); } }; q.EnqueueEvent += delegate(object o, EventArgs cargs) { lock (_class_lock) { Channel qu = (Channel)o; RpcResult rpc_reply = (RpcResult)qu.Peek(); byte [] result = (byte[])rpc_reply.Result; Address target = new AHAddress(result); if (target.Equals(queue_to_address[qu])) { correct_rpcs++; } else { incorrect_rpcs++; } } }; rpc_man.Invoke(s, q, "rpc_routing_test.GetIdentification", new object[] {}); } } //wait for 10 more seconds while (true) { int c = -1; lock (_class_lock) { c = incorrect_rpcs + missing_rpcs + correct_rpcs; } if (c < network_size * network_size) { Console.WriteLine("Going to sleep for 10 seconds."); System.Threading.Thread.Sleep(10000); } else { break; } } Console.WriteLine("Final statistics"); Console.WriteLine("correct rpcs: {0}, incorrect rpcs: {1}, missing rpcs: {2}", correct_rpcs, incorrect_rpcs, missing_rpcs); System.Environment.Exit(1); }
public static int Main(string[] args) { /** * Get the arguments */ if (args.Length < 2) { Console.Error.WriteLine("usage: SNodeExample.exe [tcp|udp] port remota_ta0 remote_ta1 ..."); return(0); } /** * Make the edge listener: */ EdgeListener el = null; int port = Int32.Parse(args[1]); if (args[0].ToLower() == "tcp") { el = new TcpEdgeListener(port); } else if (args[0].ToLower() == "udp") { el = new UdpEdgeListener(port); } /** * Create a random address for our node. * Some other application might want to select the address * a particular way, or reuse a previously selected random * address. If the addresses are not random (or the output * of secure hashes) the network might not behave correctly. */ RandomNumberGenerator rng = new RNGCryptoServiceProvider(); AHAddress tmp_add = new AHAddress(rng); Console.WriteLine("Address: {0}", tmp_add); /** * Make the node that lives in a particular * using Brunet.Messaging; * namespace (or realm) called "testspace" */ Node tmp_node = new StructuredNode(tmp_add, "testspace"); ReqrepManager rrman = tmp_node.Rrm; ReqrepExample irh = new ReqrepExample(); tmp_node.GetTypeSource(PType.Protocol.Chat).Subscribe(irh, tmp_node); /** * Add the EdgeListener */ tmp_node.AddEdgeListener(el); /** * Tell the node who it can connect to: */ for (int i = 2; i < args.Length; i++) { tmp_node.RemoteTAs.Add(TransportAddressFactory.CreateInstance(args[i])); } /** * Now we connect */ tmp_node.Connect(); Console.WriteLine("Connected"); /** * In a real application, we would create some IAHPacketHandler * objects and do: * tmp_node.Subscribe( ) * finally, we could send packets using tmp_node.Send( ) or * tmp_node.SendTo( ) */ string msg = ""; System.Text.Encoding coder = new System.Text.ASCIIEncoding(); while (true) { Console.Write("To: "); msg = Console.ReadLine(); if (msg == "q") { break; } Address dest = AddressParser.Parse(msg); while (msg != ".") { msg = Console.ReadLine(); int length = coder.GetByteCount(msg); byte[] payload = new byte[length]; coder.GetBytes(msg, 0, msg.Length, payload, 0); ISender sender = new AHSender(tmp_node, dest); rrman.SendRequest(sender, ReqrepManager.ReqrepType.Request, new CopyList(PType.Protocol.Chat, MemBlock.Reference(payload)), irh, null); } } return(1); }
/// <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); }
public static int Main(string[] args) { /** * Get the arguments */ if( args.Length < 2 ) { Console.Error.WriteLine("usage: SNodeExample.exe [tcp|udp] port remota_ta0 remote_ta1 ..."); return 0; } /** * Make the edge listener: */ EdgeListener el = null; int port = Int32.Parse( args[1] ); if( args[0].ToLower() == "tcp" ) { el = new TcpEdgeListener(port); } else if( args[0].ToLower() == "udp" ) { el = new UdpEdgeListener(port); } /** * Create a random address for our node. * Some other application might want to select the address * a particular way, or reuse a previously selected random * address. If the addresses are not random (or the output * of secure hashes) the network might not behave correctly. */ RandomNumberGenerator rng = new RNGCryptoServiceProvider(); AHAddress tmp_add = new AHAddress(rng); Console.WriteLine("Address: {0}", tmp_add); /** * Make the node that lives in a particular using Brunet.Messaging; * namespace (or realm) called "testspace" */ Node tmp_node = new StructuredNode(tmp_add, "testspace"); ReqrepManager rrman = tmp_node.Rrm; ReqrepExample irh = new ReqrepExample(); tmp_node.GetTypeSource(PType.Protocol.Chat).Subscribe(irh, tmp_node); /** * Add the EdgeListener */ tmp_node.AddEdgeListener( el ); /** * Tell the node who it can connect to: */ for(int i = 2; i < args.Length; i++) { tmp_node.RemoteTAs.Add( TransportAddressFactory.CreateInstance( args[i] ) ); } /** * Now we connect */ tmp_node.Connect(); Console.WriteLine("Connected"); /** * In a real application, we would create some IAHPacketHandler * objects and do: * tmp_node.Subscribe( ) * finally, we could send packets using tmp_node.Send( ) or * tmp_node.SendTo( ) */ string msg = ""; System.Text.Encoding coder = new System.Text.ASCIIEncoding(); while( true ) { Console.Write("To: "); msg = Console.ReadLine(); if ( msg == "q" ) { break; } Address dest = AddressParser.Parse(msg); while( msg != "." ) { msg = Console.ReadLine(); int length = coder.GetByteCount(msg); byte[] payload = new byte[length]; coder.GetBytes(msg, 0, msg.Length, payload, 0); ISender sender = new AHSender(tmp_node, dest); rrman.SendRequest(sender, ReqrepManager.ReqrepType.Request, new CopyList(PType.Protocol.Chat, MemBlock.Reference(payload)), irh , null); } } return 1; }
static void Main(string[] args) { //log.Debug( "Starting the Brunet Echo Tester" ); String config_file = args[0]; NetworkConfiguration network_configuration = NetworkConfiguration.Deserialize(config_file); int port_selection = Convert.ToInt32(args[1]); //There will be 10 different ports available for use: 0, 1, 2.. //for example, node 0 on a machine will use port_selection # 0, node 1 on a machine will use port_selection # 1 ///There will be multiple BruNet nodes on the same machine. The following is a list of possible ports used int list_size = 150; int [] port_list = new int[list_size]; for(int i = 0; i < list_size; i++){ port_list[i] = 25000 + i; } ///The line below is used when there is only one node per machine //int local_host_index = network_configuration.GetLocalHostIndex(); int desired_port = port_list[port_selection]; int local_host_index = network_configuration.GetLocalHostIndex(desired_port); NodeConfiguration this_node_configuration = (NodeConfiguration)network_configuration.Nodes[local_host_index]; TransportAddressConfiguration local_ta_configuration = (TransportAddressConfiguration)this_node_configuration.TransportAddresses[0]; short port = local_ta_configuration.Port; SHA1 sha = new SHA1CryptoServiceProvider(); String local_ta = local_ta_configuration.GetTransportAddressURI(); //We take the local transport address plus the port number to be hashed to obtain a random AHAddress byte[] hashedbytes = sha.ComputeHash(Encoding.UTF8.GetBytes(local_ta + port)); //inforce type 0 hashedbytes[Address.MemSize - 1] &= 0xFE; AHAddress _local_ahaddress = new AHAddress(hashedbytes); Node this_node = new StructuredNode( _local_ahaddress ); ///Node this_node = new HybridNode( new AHAddress( new BigInteger( 2*(local_host_index+1) ) ) ); String file_string = "./data/brunetadd" + Convert.ToString(desired_port) + ".log"; StreamWriter sw = new StreamWriter(file_string, false); sw.WriteLine( "local_address " + this_node.Address.ToBigInteger().ToString() + " " + Dns.GetHostName() + ":" + port); sw.Close(); if ( local_ta_configuration.Protocol == "tcp" ) { this_node.AddEdgeListener( new TcpEdgeListener(port) ); } else if( local_ta_configuration.Protocol == "udp" ) { this_node.AddEdgeListener( new UdpEdgeListener(port) ); } int remote_node_index = local_host_index-1; int num_remote_ta = 20; //20 nodes on the list to try to bootstrap to if (local_host_index!=0) { NodeConfiguration remote_node_configuration = (NodeConfiguration)network_configuration.Nodes[0]; TransportAddressConfiguration remote_ta_configuration = (TransportAddressConfiguration)remote_node_configuration.TransportAddresses[0]; String remote_ta = remote_ta_configuration.GetTransportAddressURI(); this_node.RemoteTAs.Add( TransportAddressFactory.CreateInstance( remote_ta ) ); } while ( (remote_node_index>=0) && (num_remote_ta>=0) ) { NodeConfiguration remote_node_configuration = (NodeConfiguration)network_configuration.Nodes[remote_node_index]; TransportAddressConfiguration remote_ta_configuration = (TransportAddressConfiguration)remote_node_configuration.TransportAddresses[0]; String remote_ta = remote_ta_configuration.GetTransportAddressURI(); this_node.RemoteTAs.Add( TransportAddressFactory.CreateInstance( remote_ta ) ); System.Console.WriteLine("Adding {0}", remote_ta); remote_node_index--; num_remote_ta--; } /* NodeConfiguration remote_node_configuration = (NodeConfiguration)network_configuration.Nodes[remote_node_index]; TransportAddressConfiguration remote_ta_configuration = (TransportAddressConfiguration)remote_node_configuration.TransportAddresses[0]; String remote_ta = remote_ta_configuration.GetTransportAddressURI(); this_node.RemoteTAs.Add( TransportAddressFactory.CreateInstance( remote_ta ) );*/ EchoTester echo_printer = new EchoTester(); this_node.GetTypeSource(PType.Protocol.Echo).Subscribe(echo_printer, this_node); this_node.Connect(); //Send a "hello message" to a random neighbor ASCIIEncoding ascii = new ASCIIEncoding(); //Make the target addresses AHAddress target = new AHAddress( new BigInteger( 2*(remote_node_index+1) ) ); string hello_msg = "hello, brunet"; int byteCount = ascii.GetByteCount(hello_msg); byte[] bytes = new byte[byteCount + 1]; ascii.GetBytes(hello_msg, 0, hello_msg.Length, bytes, 1); // update the payload // This is a request, so the first byte is greater than zero bytes[0] = (byte) 1; ICopyable p = new CopyList(PType.Protocol.AH, new AHHeader(0, 30, this_node.Address, target, AHHeader.Options.Greedy), PType.Protocol.Echo, MemBlock.Reference(bytes)); ///RDP Experiment: sending the echo packet periodically /* int seq = 0; while(true){ int start_time = System.DateTime.Now.Millisecond; this_node.Send(p); Console.WriteLine("Seq = {0}, Start Time = {1}", seq, start_time); System.Threading.Thread.Sleep(10000); seq++; }*/ ///The following is a while-loop for the local node to Brunet-ping all other nodes in the network System.Threading.Thread.Sleep(60000); ///IMPORTANT: change this parameter so we wait longer for larger network Random uid_generator = new Random( DateTime.Now.Millisecond + local_ta.GetHashCode() + port); bytes = new byte[5]; int target_index = 0, num_pings = 10, wait_time = 10000; //the wait_time is in ms double ping_time; PingWrapper pw = new PingWrapper(); while( target_index < network_configuration.Nodes.Count ){ if(target_index != local_host_index){///we do not ping the local machine NodeConfiguration target_node_configuration = (NodeConfiguration)network_configuration.Nodes[target_index]; TransportAddressConfiguration target_ta_configuration = (TransportAddressConfiguration)target_node_configuration.TransportAddresses[0]; short target_port = target_ta_configuration.Port; double ping1 = pw.Ping(target_ta_configuration.Address, 10000); double ping2 = pw.Ping(target_ta_configuration.Address, 10000); if(ping1 >= 0 || ping2 >= 0){ //we gather the data only when the node is ping-able sha = new SHA1CryptoServiceProvider(); String target_ta = target_ta_configuration.GetTransportAddressURI(); //We take the transport address plus the port number to be hashed to obtain a random AHAddress hashedbytes = sha.ComputeHash(Encoding.UTF8.GetBytes(target_ta + target_port)); //inforce type 0 hashedbytes[Address.MemSize - 1] &= 0xFE; AHAddress _target_ahaddress = new AHAddress(hashedbytes); for(int i = 0; i < num_pings; i++){ //ping and Brunet-ping the target node for a number of times int uid = uid_generator.Next(); //this is the unique id of the packet // update the payload // This is a request, so the first byte is greater than zero bytes[0] = (byte) 1; NumberSerializer.WriteInt(uid, bytes, 1); p = new CopyList(PType.Protocol.AH, new AHHeader(0, 30, this_node.Address, _target_ahaddress, AHHeader.Options.Greedy), PType.Protocol.Echo, MemBlock.Reference(bytes)); this_node.Send(p); ping_time = pw.Ping(target_ta_configuration.Address, wait_time); //wait wait_time number of ms System.Console.WriteLine("Ping time: {0}",ping_time); System.Threading.Thread.Sleep(wait_time); }//end of for-loop } }//end of if-loop target_index++; }//end of while-loop }
protected virtual StructuredNode PrepareNode(int id, AHAddress address) { if (TakenIDs.Contains(id)) { throw new Exception("ID already taken"); } StructuredNode node = new StructuredNode(address, BrunetNamespace); NodeMapping nm = new NodeMapping(); TakenIDs[id] = nm.ID = id; nm.Node = node; Nodes.Add((Address)address, nm); EdgeListener el = CreateEdgeListener(nm.ID); if (_secure_edges || _secure_senders) { byte[] blob = _se_key.ExportCspBlob(true); RSACryptoServiceProvider rsa_copy = new RSACryptoServiceProvider(); rsa_copy.ImportCspBlob(blob); CertificateMaker cm = new CertificateMaker("United States", "UFL", "ACIS", "David Wolinsky", "*****@*****.**", rsa_copy, address.ToString()); Certificate cert = cm.Sign(_ca_cert, _se_key); CertificateHandler ch = new CertificateHandler(); ch.AddCACertificate(_ca_cert.X509); ch.AddSignedCertificate(cert.X509); ProtocolSecurityOverlord so = new ProtocolSecurityOverlord(node, rsa_copy, node.Rrm, ch); so.Subscribe(node, null); node.GetTypeSource(SecurityOverlord.Security).Subscribe(so, null); nm.BSO = so; node.HeartBeatEvent += so.Heartbeat; } if (_secure_edges) { node.EdgeVerifyMethod = EdgeVerify.AddressInSubjectAltName; el = new SecureEdgeListener(el, nm.BSO); } node.AddEdgeListener(el); node.RemoteTAs = GetRemoteTAs(); ITunnelOverlap ito = null; if (NCEnable) { nm.NCService = new NCService(node, new Point()); // My evaluations show that when this is enabled the system sucks // (node as StructuredNode).Sco.TargetSelector = new VivaldiTargetSelector(node, ncservice); ito = new NCTunnelOverlap(nm.NCService); } else { ito = new SimpleTunnelOverlap(); } if (_broken != 0) { el = new Tunnel.TunnelEdgeListener(node, ito); node.AddEdgeListener(el); } // Enables Dht data store new TableServer(node); return(node); }
/// <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); }
protected virtual StructuredNode PrepareNode(int id, AHAddress address) { if(TakenIDs.Contains(id)) { throw new Exception("ID already taken"); } StructuredNode node = new StructuredNode(address, BrunetNamespace); NodeMapping nm = new NodeMapping(); TakenIDs[id] = nm.ID = id; nm.Node = node; Nodes.Add((Address) address, nm); EdgeListener el = CreateEdgeListener(nm.ID); if(SecureEdges || SecureSenders) { byte[] blob = SEKey.ExportCspBlob(true); RSACryptoServiceProvider rsa_copy = new RSACryptoServiceProvider(); rsa_copy.ImportCspBlob(blob); CertificateMaker cm = new CertificateMaker("United States", "UFL", "ACIS", "David Wolinsky", "*****@*****.**", rsa_copy, address.ToString()); Certificate cert = cm.Sign(CACert, SEKey); CertificateHandler ch = new CertificateHandler(); ch.AddCACertificate(CACert.X509); ch.AddSignedCertificate(cert.X509); ProtocolSecurityOverlord so = new ProtocolSecurityOverlord(node, rsa_copy, node.Rrm, ch); so.Subscribe(node, null); node.GetTypeSource(SecurityOverlord.Security).Subscribe(so, null); nm.BSO = so; node.HeartBeatEvent += so.Heartbeat; } if(SecureEdges) { node.EdgeVerifyMethod = EdgeVerify.AddressInSubjectAltName; el = new SecureEdgeListener(el, nm.BSO); } node.AddEdgeListener(el); node.RemoteTAs = GetRemoteTAs(); ITunnelOverlap ito = null; if(NCEnable) { nm.NCService = new NCService(node, new Point()); // My evaluations show that when this is enabled the system sucks // (node as StructuredNode).Sco.TargetSelector = new VivaldiTargetSelector(node, ncservice); ito = new NCTunnelOverlap(nm.NCService); } else { ito = new SimpleTunnelOverlap(); } if(Broken != 0) { el = new Tunnel.TunnelEdgeListener(node, ito); node.AddEdgeListener(el); } // Enables Dht data store new Brunet.DistributedServices.TableServer(node); return node; }