Skip to content

Commit

Permalink
添加项目文件。
Browse files Browse the repository at this point in the history
  • Loading branch information
TeaRed-LeafFall committed Jul 25, 2024
1 parent 325531f commit 8f38bd2
Show file tree
Hide file tree
Showing 11 changed files with 316 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .idea/.idea.IP address Spawn/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/.idea.IP address Spawn/.idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/.idea.IP address Spawn/.idea/indexLayout.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

85 changes: 85 additions & 0 deletions .idea/.idea.IPaddressSpawn/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
41 changes: 41 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
16 changes: 16 additions & 0 deletions IP address Spawn.sln
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions IPaddressSpawn.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -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.
83 changes: 83 additions & 0 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -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<int> 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<int>();
if (inputStartIps.Length != 4)
{
Console.WriteLine("输入不合规");
goto inputIp;
}
else
{
foreach (var str in inputStartIps)
{
ipd.Add(int.Parse(str));
}
}
return ipd;
}
}
12 changes: 12 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# IPaddressSpawn
一个IP地址生成器

这是一个用于生成IP地址的C#程序,用户可以输入起始IP地址和结束IP地址,程序将生成所有在这两个IP地址之间的地址

> 注意:
>
> **本工具不再更新**,程序编写于2024/1/26
>
> 本项目在2024/7/26上传
>
> 这个是老的完成项目,所以不需要更新了。

0 comments on commit 8f38bd2

Please sign in to comment.