// adds a node to the pool protected static void add_node(bool output) { AHAddress address = new AHAddress(new RNGCryptoServiceProvider()); Node node = new StructuredNode(address, brunet_namespace); NodeMapping nm = new NodeMapping(); nm.Node = node; nodes.Add((Address) address, nm); nm.Port = TakenPorts.Count; while(TakenPorts.Contains(nm.Port)) { nm.Port = rand.Next(0, 65535); } TAAuthorizer auth = null; if(broken != 0) { auth = new BrokenTAAuth(broken); } EdgeListener el = new SimulationEdgeListener(nm.Port, 0, auth, true); if(secure_edges || secure_senders) { 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); BrunetSecurityOverlord so = new BrunetSecurityOverlord(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) { el = new SecureEdgeListener(el, nm.BSO); } node.AddEdgeListener(el); if(broken != 0) { el = new TunnelEdgeListener(node); node.AddEdgeListener(el); } ArrayList RemoteTAs = new ArrayList(); for(int i = 0; i < 5 && i < TakenPorts.Count; i++) { int rport = (int) TakenPorts.GetByIndex(rand.Next(0, TakenPorts.Count)); RemoteTAs.Add(TransportAddressFactory.CreateInstance("brunet.function://127.0.0.1:" + rport)); } node.RemoteTAs = RemoteTAs; TakenPorts[nm.Port] = nm.Port; if(output) { Console.WriteLine("Adding: " + nm.Node.Address); } node.Connect(); network_size++; }
// adds a node to the pool protected static void add_node(bool output) { AHAddress address = new AHAddress(new RNGCryptoServiceProvider()); Node node = new StructuredNode(address, brunet_namespace); NodeMapping nm = new NodeMapping(); nm.Node = node; nodes.Add((Address) address, nm); nm.Port = TakenPorts.Count; while(TakenPorts.Contains(nm.Port)) { nm.Port = rand.Next(0, 65535); } TAAuthorizer auth = null; if(broken != 0) { auth = new BrokenTAAuth(broken); } EdgeListener el = new FunctionEdgeListener(nm.Port, 0, auth, true); node.AddEdgeListener(el); if(broken != 0) { el = new TunnelEdgeListener(node); node.AddEdgeListener(el); } ArrayList RemoteTAs = new ArrayList(); for(int i = 0; i < 5 && i < TakenPorts.Count; i++) { int rport = (int) TakenPorts.GetByIndex(rand.Next(0, TakenPorts.Count)); RemoteTAs.Add(TransportAddressFactory.CreateInstance("brunet.function://127.0.0.1:" + rport)); } node.RemoteTAs = RemoteTAs; TakenPorts[nm.Port] = nm.Port; if(output) { Console.WriteLine("Adding: " + nm.Node.Address); } node.Connect(); network_size++; }
/// <summary>Return the SimulationEdgeListener.</summary> protected virtual EdgeListener CreateEdgeListener(int id) { TAAuthorizer auth = null; if(_broken != 0 && id > 0) { auth = new BrokenTAAuth(_broken); } return new SimulationEdgeListener(id, _parameters.DropRate, auth, true); }