diff --git a/.idea/.idea.IP address Spawn/.idea/.gitignore b/.idea/.idea.IP address Spawn/.idea/.gitignore new file mode 100644 index 0000000..bd36868 --- /dev/null +++ b/.idea/.idea.IP address Spawn/.idea/.gitignore @@ -0,0 +1,13 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# Rider 忽略的文件 +/contentModel.xml +/modules.xml +/projectSettingsUpdater.xml +/.idea.IPaddressSpawn.iml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/.idea.IP address Spawn/.idea/.name b/.idea/.idea.IP address Spawn/.idea/.name new file mode 100644 index 0000000..871fd46 --- /dev/null +++ b/.idea/.idea.IP address Spawn/.idea/.name @@ -0,0 +1 @@ +IP address Spawn \ No newline at end of file diff --git a/.idea/.idea.IP address Spawn/.idea/indexLayout.xml b/.idea/.idea.IP address Spawn/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/.idea/.idea.IP address Spawn/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/.idea.IPaddressSpawn/.idea/workspace.xml b/.idea/.idea.IPaddressSpawn/.idea/workspace.xml new file mode 100644 index 0000000..be2bfec --- /dev/null +++ b/.idea/.idea.IPaddressSpawn/.idea/workspace.xml @@ -0,0 +1,85 @@ + + + + IPaddressSpawn.csproj + + + + + + + { + "associatedIndex": 2 +} + + + + + + + + + + + + + 1706275406161 + + + + + + + + \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..e45b3d0 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,26 @@ +{ + "version": "0.2.0", + "configurations": [ + { + // 使用 IntelliSense 找出 C# 调试存在哪些属性 + // 将悬停用于现有属性的说明 + // 有关详细信息,请访问 https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // 如果已更改目标框架,请确保更新程序路径。 + "program": "${workspaceFolder}/bin/Debug/net8.0/IPaddressSpawn.dll", + "args": [], + "cwd": "${workspaceFolder}", + // 有关“控制台”字段的详细信息,请参阅 https://aka.ms/VSCode-CS-LaunchJson-Console + "console": "internalConsole", + "stopAtEntry": false + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..e7cd61a --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,41 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/IP address Spawn.sln", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary;ForceNoAlign" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/IP address Spawn.sln", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary;ForceNoAlign" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "--project", + "${workspaceFolder}/IP address Spawn.sln" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/IP address Spawn.sln b/IP address Spawn.sln new file mode 100644 index 0000000..0b9a3a1 --- /dev/null +++ b/IP address Spawn.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IPaddressSpawn", "IPaddressSpawn.csproj", "{721111D1-C998-450A-80C6-3A343A65589F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {721111D1-C998-450A-80C6-3A343A65589F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {721111D1-C998-450A-80C6-3A343A65589F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {721111D1-C998-450A-80C6-3A343A65589F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {721111D1-C998-450A-80C6-3A343A65589F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/IPaddressSpawn.csproj b/IPaddressSpawn.csproj new file mode 100644 index 0000000..2f4fc77 --- /dev/null +++ b/IPaddressSpawn.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..9d8ba16 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 AuthorZiXi + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..72610bd --- /dev/null +++ b/Program.cs @@ -0,0 +1,83 @@ +namespace IPaddressSpawn; +public static class Program +{ + public static void Main() + { + Console.WriteLine("欢迎使用 IP address Spawn!"); + var startIp = InputIp("现在请输入开始的Ip地址(xxx.xxx.xxx.xxx):"); + var endIp = InputIp("现在请输入结束的Ip地址(xxx.xxx.xxx.xxx):"); + + Console.Write("现在请输入最大的地址单项数据(数字):"); + var inputMaxInt = int.Parse(Console.ReadLine() ?? throw new InvalidOperationException()); + var ip1 = startIp[0]; + var ip2 = startIp[1]; + var ip3 = startIp[2]; + var ip4 = startIp[3]; + var count = 0; + + + inputpath: + // 获取用户输入的文件路径 + Console.WriteLine("请输入要保存的文件路径:"); + var filePath = Console.ReadLine(); + if (Path.Exists(filePath) || string.IsNullOrEmpty(filePath)) + { + goto inputpath; + } + + + using (var writer = new StreamWriter(filePath)) + { + Parallel.For(0, endIp[0] + 1, ip1 => + { + for (var ip2 = ip1 == 0 ? 0 : 1; ip2 <= (ip1 == endIp[0] ? endIp[1] : inputMaxInt); ip2++) + { + for (var ip3 = ip1 == 0 && ip2 == 0 ? 0 : 1; ip3 <= (ip1 == endIp[0] && ip2 == endIp[1] ? endIp[2] : inputMaxInt); ip3++) + { + for (var ip4 = ip1 == 0 && ip2 == 0 && ip3 == 0 ? 0 : 1; ip4 <= (ip1 == endIp[0] && ip2 == endIp[1] && ip3 == endIp[2] ? endIp[3] : inputMaxInt); ip4++) + { + var ipAddress = $"{ip1}.{ip2}.{ip3}.{ip4}"; + count++; + var output = $"{ipAddress}\n"; + Console.Write(count + " - " + output); + writer.Write(output); + } + } + } + }); + } + + Console.WriteLine("一共生成了 " + count + " 条数据!"); + + Console.WriteLine("任务执行完成!按任意键退出"); + Console.ReadLine(); + } + + + private static List InputIp(string message) + { + inputIp: + Console.Write(message); + var input=Console.ReadLine(); + if (string.IsNullOrEmpty(input)) + { + Console.WriteLine("输入不合规"); + goto inputIp; + } + var inputStartIps = input.Split('.'); + var ipd = new List(); + if (inputStartIps.Length != 4) + { + Console.WriteLine("输入不合规"); + goto inputIp; + } + else + { + foreach (var str in inputStartIps) + { + ipd.Add(int.Parse(str)); + } + } + return ipd; + } +} \ No newline at end of file diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..0a5b6d9 --- /dev/null +++ b/readme.md @@ -0,0 +1,12 @@ +# IPaddressSpawn +一个IP地址生成器 + +这是一个用于生成IP地址的C#程序,用户可以输入起始IP地址和结束IP地址,程序将生成所有在这两个IP地址之间的地址 + +> 注意: +> +> **本工具不再更新**,程序编写于2024/1/26 +> +> 本项目在2024/7/26上传 +> +> 这个是老的完成项目,所以不需要更新了。 \ No newline at end of file