internal static bool GenerateRandomIPReplacement(out string __result) { while (true) { var ip = Utils.random.Next(254) + 1 + "." + (Utils.random.Next(254) + 1) + "." + (Utils.random.Next(254) + 1) + "." + (Utils.random.Next(254) + 1); if (ComputerLookup.FindByIp(ip, false) == null) { __result = ip; return(false); } } }
internal static void OnISPChangeIP(ILContext il) { ILCursor c = new ILCursor(il); c.GotoNext(MoveType.After, x => x.MatchCallOrCallvirt(AccessTools.Method(typeof(NetworkMap), nameof(NetworkMap.generateRandomIP)))); c.Emit(OpCodes.Dup); c.Emit(OpCodes.Ldarg_0); c.Emit(OpCodes.Ldfld, AccessTools.Field(typeof(ISPDaemon), nameof(ISPDaemon.scannedComputer))); c.Emit(OpCodes.Ldfld, AccessTools.Field(typeof(Computer), nameof(Computer.ip))); c.EmitDelegate <Action <string, string> >((newIp, oldIp) => { if (ComputerLookup.FindByIp(newIp) == null) { ComputerLookup.NotifyIPChange(oldIp, newIp); } }); }
internal static bool ScanReplacement(string[] args, OS os) { if (args.Length > 1) { Computer computer = ComputerLookup.FindByIp(args[1]); if (computer == null) { computer = ComputerLookup.FindByName(args[1]); } if (computer != null) { os.netMap.discoverNode(computer); os.write("Found Terminal : " + computer.name + "@" + computer.ip); } return(false); } return(true); }
internal static bool ScanReplacement(string[] args, OS os) { if (args.Length > 1) { Computer computer = ComputerLookup.FindByIp(args[1]); if (computer == null) { computer = ComputerLookup.FindByName(args[1]); } if (computer != null) { os.netMap.discoverNode(computer); os.write("Found Terminal : " + computer.name + "@" + computer.ip); } return(false); } Computer computer2 = ((os.connectedComp != null) ? os.connectedComp : os.thisComputer); if (os.hasConnectionPermission(admin: true)) { os.write("Scanning..."); for (int i = 0; i < computer2.links.Count; i++) { if (!os.netMap.visibleNodes.Contains(computer2.links[i])) { os.netMap.visibleNodes.Add(computer2.links[i]); } os.netMap.nodes[computer2.links[i]].highlightFlashTime = 1f; os.write("Found Terminal : " + os.netMap.nodes[computer2.links[i]].name + "@" + os.netMap.nodes[computer2.links[i]].ip); os.netMap.lastAddedNode = os.netMap.nodes[computer2.links[i]]; Thread.Sleep(400); } os.write("Scan Complete\n"); } else { os.write("Scanning Requires Admin Access\n"); } return(false); }