// firewall set at core level so that networks can exist on internet and on public LANs simultaneously public void SetFirewallType(FirewallType type) { // check if already set if (Firewall == type) { return; } // if client previously blocked, cancel any current searches through proxy if (Firewall == FirewallType.Blocked) { lock (Network.Searches.Active) foreach (DhtSearch search in Network.Searches.Active) { search.ProxyTcp = null; } } Firewall = type; if (type == FirewallType.Open) { Network.FirewallChangedtoOpen(); } if (type == FirewallType.NAT) { Network.FirewallChangedtoNAT(); } if (type == FirewallType.Blocked) { } string message = "Firewall changed to " + type.ToString(); Network.UpdateLog("Network", message); Network.UpdateLog("general", message); }
// firewall set at core level so that networks can exist on internet and on public LANs simultaneously public void SetFirewallType(FirewallType type) { // check if already set if (Firewall == type) return; // if client previously blocked, cancel any current searches through proxy if (Firewall == FirewallType.Blocked) lock (Network.Searches.Active) foreach (DhtSearch search in Network.Searches.Active) search.ProxyTcp = null; Firewall = type; if (type == FirewallType.Open) Network.FirewallChangedtoOpen(); if (type == FirewallType.NAT) Network.FirewallChangedtoNAT(); if (type == FirewallType.Blocked) { } string message = "Firewall changed to " + type.ToString(); Network.UpdateLog("Network", message); Network.UpdateLog("general", message); }
public void ConsoleCommand(string command) { if (command == "clear") { ConsoleText.Clear(); } if (command == "pause") { PauseLog = !PauseLog; } ConsoleLog("> " + command); try { string[] commands = command.Split(' '); if (commands.Length == 0) { return; } if (commands[0] == "testDht" && commands.Length == 2) { int count = Convert.ToInt32(commands[1]); for (int i = 0; i < count; i++) { RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); UInt64 kid = Utilities.StrongRandUInt64(rng); // create random contact DhtContact contact = new DhtContact(kid, 7, new IPAddress(7), 7, 7); // add to routing Network.Routing.Add(contact); } } if (commands[0] == "gc") { GC.Collect(); } if (commands[0] == "killtcp") { /*ConsoleLog(TcpControl.Connections.Count.ToString() + " tcp sockets on list"); * * lock(TcpControl.Connections.SyncRoot) * foreach(TcpConnect connection in TcpControl.Connections) * connection.CleanClose("Force Disconnect");*/ } if (commands[0] == "fwstatus") { ConsoleLog("Status set to " + Firewall.ToString()); } if (commands[0] == "fwset" && commands.Length > 1) { if (commands[1] == "open") { SetFirewallType(FirewallType.Open); } if (commands[1] == "nat") { SetFirewallType(FirewallType.NAT); } if (commands[1] == "blocked") { SetFirewallType(FirewallType.Blocked); } } if (commands[0] == "listening") { /*ConsoleLog("Listening for TCP on port " + TcpControl.ListenPort.ToString()); * ConsoleLog("Listening for UDP on port " + UdpControl.ListenPort.ToString());*/ } if (commands[0] == "ping" && commands.Length > 0) { //string[] addr = commands[1].Split(':'); //GlobalNet.Send_Ping(IPAddress.Parse(addr[0]), Convert.ToUInt16(addr[1])); } if (commands[0] == "tcptest" && commands.Length > 0) { string[] addr = commands[1].Split(':'); //TcpControl.MakeOutbound(IPAddress.Parse(addr[0]), Convert.ToUInt16(addr[1]),0); } } catch (Exception ex) { ConsoleLog("Exception " + ex.Message); } }