mirror of
https://github.com/Leonmmcoset/CMLeonOS.git
synced 2026-03-03 15:30:27 +00:00
网络初始化++
This commit is contained in:
29
.VSCodeCounter/2026-02-02_16-15-16/details.md
Normal file
29
.VSCodeCounter/2026-02-02_16-15-16/details.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# Details
|
||||
|
||||
Date : 2026-02-02 16:15:16
|
||||
|
||||
Directory c:\\Users\\leon\\source\\repos\\CMLeonOS\\CMLeonOS
|
||||
|
||||
Total : 14 files, 4271 codes, 214 comments, 649 blanks, all 5134 lines
|
||||
|
||||
[Summary](results.md) / Details / [Diff Summary](diff.md) / [Diff Details](diff-details.md)
|
||||
|
||||
## Files
|
||||
| filename | language | code | comment | blank | total |
|
||||
| :--- | :--- | ---: | ---: | ---: | ---: |
|
||||
| [Branswe.cs](/Branswe.cs) | C# | 482 | 28 | 53 | 563 |
|
||||
| [Branswe.md](/Branswe.md) | Markdown | 261 | 0 | 67 | 328 |
|
||||
| [CMLeonOS.csproj](/CMLeonOS.csproj) | XML | 42 | 1 | 5 | 48 |
|
||||
| [CUI.cs](/CUI.cs) | C# | 122 | 8 | 28 | 158 |
|
||||
| [Editor.cs](/Editor.cs) | C# | 257 | 47 | 27 | 331 |
|
||||
| [EnvironmentVariableManager.cs](/EnvironmentVariableManager.cs) | C# | 151 | 5 | 17 | 173 |
|
||||
| [FileSystem.cs](/FileSystem.cs) | C# | 324 | 17 | 30 | 371 |
|
||||
| [Kernel.cs](/Kernel.cs) | C# | 159 | 28 | 32 | 219 |
|
||||
| [LISENCE.md](/LISENCE.md) | Markdown | 485 | 0 | 110 | 595 |
|
||||
| [SHA256.cs](/SHA256.cs) | C# | 179 | 6 | 41 | 226 |
|
||||
| [Shell.cs](/Shell.cs) | C# | 1,289 | 48 | 156 | 1,493 |
|
||||
| [UserSystem.cs](/UserSystem.cs) | C# | 492 | 26 | 78 | 596 |
|
||||
| [Version.cs](/Version.cs) | C# | 22 | 0 | 5 | 27 |
|
||||
| [global.json](/global.json) | JSON | 6 | 0 | 0 | 6 |
|
||||
|
||||
[Summary](results.md) / Details / [Diff Summary](diff.md) / [Diff Details](diff-details.md)
|
||||
15
.VSCodeCounter/2026-02-02_16-15-16/diff-details.md
Normal file
15
.VSCodeCounter/2026-02-02_16-15-16/diff-details.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# Diff Details
|
||||
|
||||
Date : 2026-02-02 16:15:16
|
||||
|
||||
Directory c:\\Users\\leon\\source\\repos\\CMLeonOS\\CMLeonOS
|
||||
|
||||
Total : 0 files, 0 codes, 0 comments, 0 blanks, all 0 lines
|
||||
|
||||
[Summary](results.md) / [Details](details.md) / [Diff Summary](diff.md) / Diff Details
|
||||
|
||||
## Files
|
||||
| filename | language | code | comment | blank | total |
|
||||
| :--- | :--- | ---: | ---: | ---: | ---: |
|
||||
|
||||
[Summary](results.md) / [Details](details.md) / [Diff Summary](diff.md) / Diff Details
|
||||
2
.VSCodeCounter/2026-02-02_16-15-16/diff.csv
Normal file
2
.VSCodeCounter/2026-02-02_16-15-16/diff.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
"filename", "language", "", "comment", "blank", "total"
|
||||
"Total", "-", , 0, 0, 0
|
||||
|
19
.VSCodeCounter/2026-02-02_16-15-16/diff.md
Normal file
19
.VSCodeCounter/2026-02-02_16-15-16/diff.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Diff Summary
|
||||
|
||||
Date : 2026-02-02 16:15:16
|
||||
|
||||
Directory c:\\Users\\leon\\source\\repos\\CMLeonOS\\CMLeonOS
|
||||
|
||||
Total : 0 files, 0 codes, 0 comments, 0 blanks, all 0 lines
|
||||
|
||||
[Summary](results.md) / [Details](details.md) / Diff Summary / [Diff Details](diff-details.md)
|
||||
|
||||
## Languages
|
||||
| language | files | code | comment | blank | total |
|
||||
| :--- | ---: | ---: | ---: | ---: | ---: |
|
||||
|
||||
## Directories
|
||||
| path | files | code | comment | blank | total |
|
||||
| :--- | ---: | ---: | ---: | ---: | ---: |
|
||||
|
||||
[Summary](results.md) / [Details](details.md) / Diff Summary / [Diff Details](diff-details.md)
|
||||
22
.VSCodeCounter/2026-02-02_16-15-16/diff.txt
Normal file
22
.VSCodeCounter/2026-02-02_16-15-16/diff.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
Date : 2026-02-02 16:15:16
|
||||
Directory : c:\Users\leon\source\repos\CMLeonOS\CMLeonOS
|
||||
Total : 0 files, 0 codes, 0 comments, 0 blanks, all 0 lines
|
||||
|
||||
Languages
|
||||
+----------+------------+------------+------------+------------+------------+
|
||||
| language | files | code | comment | blank | total |
|
||||
+----------+------------+------------+------------+------------+------------+
|
||||
+----------+------------+------------+------------+------------+------------+
|
||||
|
||||
Directories
|
||||
+------+------------+------------+------------+------------+------------+
|
||||
| path | files | code | comment | blank | total |
|
||||
+------+------------+------------+------------+------------+------------+
|
||||
+------+------------+------------+------------+------------+------------+
|
||||
|
||||
Files
|
||||
+----------+----------+------------+------------+------------+------------+
|
||||
| filename | language | code | comment | blank | total |
|
||||
+----------+----------+------------+------------+------------+------------+
|
||||
| Total | | 0 | 0 | 0 | 0 |
|
||||
+----------+----------+------------+------------+------------+------------+
|
||||
16
.VSCodeCounter/2026-02-02_16-15-16/results.csv
Normal file
16
.VSCodeCounter/2026-02-02_16-15-16/results.csv
Normal file
@@ -0,0 +1,16 @@
|
||||
"filename", "language", "C#", "XML", "Markdown", "JSON", "comment", "blank", "total"
|
||||
"c:\Users\leon\source\repos\CMLeonOS\CMLeonOS\Branswe.cs", "C#", 482, 0, 0, 0, 28, 53, 563
|
||||
"c:\Users\leon\source\repos\CMLeonOS\CMLeonOS\Branswe.md", "Markdown", 0, 0, 261, 0, 0, 67, 328
|
||||
"c:\Users\leon\source\repos\CMLeonOS\CMLeonOS\CMLeonOS.csproj", "XML", 0, 42, 0, 0, 1, 5, 48
|
||||
"c:\Users\leon\source\repos\CMLeonOS\CMLeonOS\CUI.cs", "C#", 122, 0, 0, 0, 8, 28, 158
|
||||
"c:\Users\leon\source\repos\CMLeonOS\CMLeonOS\Editor.cs", "C#", 257, 0, 0, 0, 47, 27, 331
|
||||
"c:\Users\leon\source\repos\CMLeonOS\CMLeonOS\EnvironmentVariableManager.cs", "C#", 151, 0, 0, 0, 5, 17, 173
|
||||
"c:\Users\leon\source\repos\CMLeonOS\CMLeonOS\FileSystem.cs", "C#", 324, 0, 0, 0, 17, 30, 371
|
||||
"c:\Users\leon\source\repos\CMLeonOS\CMLeonOS\Kernel.cs", "C#", 159, 0, 0, 0, 28, 32, 219
|
||||
"c:\Users\leon\source\repos\CMLeonOS\CMLeonOS\LISENCE.md", "Markdown", 0, 0, 485, 0, 0, 110, 595
|
||||
"c:\Users\leon\source\repos\CMLeonOS\CMLeonOS\SHA256.cs", "C#", 179, 0, 0, 0, 6, 41, 226
|
||||
"c:\Users\leon\source\repos\CMLeonOS\CMLeonOS\Shell.cs", "C#", 1289, 0, 0, 0, 48, 156, 1493
|
||||
"c:\Users\leon\source\repos\CMLeonOS\CMLeonOS\UserSystem.cs", "C#", 492, 0, 0, 0, 26, 78, 596
|
||||
"c:\Users\leon\source\repos\CMLeonOS\CMLeonOS\Version.cs", "C#", 22, 0, 0, 0, 0, 5, 27
|
||||
"c:\Users\leon\source\repos\CMLeonOS\CMLeonOS\global.json", "JSON", 0, 0, 0, 6, 0, 0, 6
|
||||
"Total", "-", 3477, 42, 746, 6, 214, 649, 5134
|
||||
|
1
.VSCodeCounter/2026-02-02_16-15-16/results.json
Normal file
1
.VSCodeCounter/2026-02-02_16-15-16/results.json
Normal file
@@ -0,0 +1 @@
|
||||
{"file:///c%3A/Users/leon/source/repos/CMLeonOS/CMLeonOS/Editor.cs":{"language":"C#","code":257,"comment":47,"blank":27},"file:///c%3A/Users/leon/source/repos/CMLeonOS/CMLeonOS/CMLeonOS.csproj":{"language":"XML","code":42,"comment":1,"blank":5},"file:///c%3A/Users/leon/source/repos/CMLeonOS/CMLeonOS/CUI.cs":{"language":"C#","code":122,"comment":8,"blank":28},"file:///c%3A/Users/leon/source/repos/CMLeonOS/CMLeonOS/EnvironmentVariableManager.cs":{"language":"C#","code":151,"comment":5,"blank":17},"file:///c%3A/Users/leon/source/repos/CMLeonOS/CMLeonOS/Version.cs":{"language":"C#","code":22,"comment":0,"blank":5},"file:///c%3A/Users/leon/source/repos/CMLeonOS/CMLeonOS/Branswe.cs":{"language":"C#","code":482,"comment":28,"blank":53},"file:///c%3A/Users/leon/source/repos/CMLeonOS/CMLeonOS/Branswe.md":{"language":"Markdown","code":261,"comment":0,"blank":67},"file:///c%3A/Users/leon/source/repos/CMLeonOS/CMLeonOS/UserSystem.cs":{"language":"C#","code":492,"comment":26,"blank":78},"file:///c%3A/Users/leon/source/repos/CMLeonOS/CMLeonOS/Shell.cs":{"language":"C#","code":1289,"comment":48,"blank":156},"file:///c%3A/Users/leon/source/repos/CMLeonOS/CMLeonOS/SHA256.cs":{"language":"C#","code":179,"comment":6,"blank":41},"file:///c%3A/Users/leon/source/repos/CMLeonOS/CMLeonOS/LISENCE.md":{"language":"Markdown","code":485,"comment":0,"blank":110},"file:///c%3A/Users/leon/source/repos/CMLeonOS/CMLeonOS/Kernel.cs":{"language":"C#","code":159,"comment":28,"blank":32},"file:///c%3A/Users/leon/source/repos/CMLeonOS/CMLeonOS/global.json":{"language":"JSON","code":6,"comment":0,"blank":0},"file:///c%3A/Users/leon/source/repos/CMLeonOS/CMLeonOS/FileSystem.cs":{"language":"C#","code":324,"comment":17,"blank":30}}
|
||||
24
.VSCodeCounter/2026-02-02_16-15-16/results.md
Normal file
24
.VSCodeCounter/2026-02-02_16-15-16/results.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# Summary
|
||||
|
||||
Date : 2026-02-02 16:15:16
|
||||
|
||||
Directory c:\\Users\\leon\\source\\repos\\CMLeonOS\\CMLeonOS
|
||||
|
||||
Total : 14 files, 4271 codes, 214 comments, 649 blanks, all 5134 lines
|
||||
|
||||
Summary / [Details](details.md) / [Diff Summary](diff.md) / [Diff Details](diff-details.md)
|
||||
|
||||
## Languages
|
||||
| language | files | code | comment | blank | total |
|
||||
| :--- | ---: | ---: | ---: | ---: | ---: |
|
||||
| C# | 10 | 3,477 | 213 | 467 | 4,157 |
|
||||
| Markdown | 2 | 746 | 0 | 177 | 923 |
|
||||
| XML | 1 | 42 | 1 | 5 | 48 |
|
||||
| JSON | 1 | 6 | 0 | 0 | 6 |
|
||||
|
||||
## Directories
|
||||
| path | files | code | comment | blank | total |
|
||||
| :--- | ---: | ---: | ---: | ---: | ---: |
|
||||
| . | 14 | 4,271 | 214 | 649 | 5,134 |
|
||||
|
||||
Summary / [Details](details.md) / [Diff Summary](diff.md) / [Diff Details](diff-details.md)
|
||||
41
.VSCodeCounter/2026-02-02_16-15-16/results.txt
Normal file
41
.VSCodeCounter/2026-02-02_16-15-16/results.txt
Normal file
@@ -0,0 +1,41 @@
|
||||
Date : 2026-02-02 16:15:16
|
||||
Directory : c:\Users\leon\source\repos\CMLeonOS\CMLeonOS
|
||||
Total : 14 files, 4271 codes, 214 comments, 649 blanks, all 5134 lines
|
||||
|
||||
Languages
|
||||
+----------+------------+------------+------------+------------+------------+
|
||||
| language | files | code | comment | blank | total |
|
||||
+----------+------------+------------+------------+------------+------------+
|
||||
| C# | 10 | 3,477 | 213 | 467 | 4,157 |
|
||||
| Markdown | 2 | 746 | 0 | 177 | 923 |
|
||||
| XML | 1 | 42 | 1 | 5 | 48 |
|
||||
| JSON | 1 | 6 | 0 | 0 | 6 |
|
||||
+----------+------------+------------+------------+------------+------------+
|
||||
|
||||
Directories
|
||||
+----------------------------------------------------------------------------+------------+------------+------------+------------+------------+
|
||||
| path | files | code | comment | blank | total |
|
||||
+----------------------------------------------------------------------------+------------+------------+------------+------------+------------+
|
||||
| . | 14 | 4,271 | 214 | 649 | 5,134 |
|
||||
+----------------------------------------------------------------------------+------------+------------+------------+------------+------------+
|
||||
|
||||
Files
|
||||
+----------------------------------------------------------------------------+----------+------------+------------+------------+------------+
|
||||
| filename | language | code | comment | blank | total |
|
||||
+----------------------------------------------------------------------------+----------+------------+------------+------------+------------+
|
||||
| c:\Users\leon\source\repos\CMLeonOS\CMLeonOS\Branswe.cs | C# | 482 | 28 | 53 | 563 |
|
||||
| c:\Users\leon\source\repos\CMLeonOS\CMLeonOS\Branswe.md | Markdown | 261 | 0 | 67 | 328 |
|
||||
| c:\Users\leon\source\repos\CMLeonOS\CMLeonOS\CMLeonOS.csproj | XML | 42 | 1 | 5 | 48 |
|
||||
| c:\Users\leon\source\repos\CMLeonOS\CMLeonOS\CUI.cs | C# | 122 | 8 | 28 | 158 |
|
||||
| c:\Users\leon\source\repos\CMLeonOS\CMLeonOS\Editor.cs | C# | 257 | 47 | 27 | 331 |
|
||||
| c:\Users\leon\source\repos\CMLeonOS\CMLeonOS\EnvironmentVariableManager.cs | C# | 151 | 5 | 17 | 173 |
|
||||
| c:\Users\leon\source\repos\CMLeonOS\CMLeonOS\FileSystem.cs | C# | 324 | 17 | 30 | 371 |
|
||||
| c:\Users\leon\source\repos\CMLeonOS\CMLeonOS\Kernel.cs | C# | 159 | 28 | 32 | 219 |
|
||||
| c:\Users\leon\source\repos\CMLeonOS\CMLeonOS\LISENCE.md | Markdown | 485 | 0 | 110 | 595 |
|
||||
| c:\Users\leon\source\repos\CMLeonOS\CMLeonOS\SHA256.cs | C# | 179 | 6 | 41 | 226 |
|
||||
| c:\Users\leon\source\repos\CMLeonOS\CMLeonOS\Shell.cs | C# | 1,289 | 48 | 156 | 1,493 |
|
||||
| c:\Users\leon\source\repos\CMLeonOS\CMLeonOS\UserSystem.cs | C# | 492 | 26 | 78 | 596 |
|
||||
| c:\Users\leon\source\repos\CMLeonOS\CMLeonOS\Version.cs | C# | 22 | 0 | 5 | 27 |
|
||||
| c:\Users\leon\source\repos\CMLeonOS\CMLeonOS\global.json | JSON | 6 | 0 | 0 | 6 |
|
||||
| Total | | 4,271 | 214 | 649 | 5,134 |
|
||||
+----------------------------------------------------------------------------+----------+------------+------------+------------+------------+
|
||||
33
Kernel.cs
33
Kernel.cs
@@ -1,9 +1,12 @@
|
||||
using Cosmos.HAL;
|
||||
using Cosmos.System.Network.Config;
|
||||
using Cosmos.System.Network.IPv4.UDP.DHCP;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
using System.Text;
|
||||
using Sys = Cosmos.System;
|
||||
using Cosmos.System.Network.IPv4.UDP.DHCP;
|
||||
|
||||
namespace CMLeonOS
|
||||
{
|
||||
@@ -53,6 +56,7 @@ namespace CMLeonOS
|
||||
SystemStartTime = DateTime.Now;
|
||||
Console.WriteLine($"System started at: {SystemStartTime.ToString("yyyy-MM-dd HH:mm:ss")}");
|
||||
|
||||
// 初始化网络
|
||||
Console.WriteLine("Starting network...");
|
||||
try
|
||||
{
|
||||
@@ -60,8 +64,17 @@ namespace CMLeonOS
|
||||
{
|
||||
throw new Exception("No network devices are available.");
|
||||
}
|
||||
var netDevice = NetworkDevice.Devices[0];
|
||||
using var dhcp = new DHCPClient();
|
||||
if (netDevice.Ready == true) {
|
||||
ShowSuccess("Network device ready.");
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowError("Network device is not ready.");
|
||||
}
|
||||
dhcp.SendDiscoverPacket();
|
||||
Console.WriteLine($"Local IP: {NetworkConfiguration.CurrentAddress.ToString()}");
|
||||
ShowSuccess("Network started.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -103,6 +116,22 @@ namespace CMLeonOS
|
||||
ShowSuccess("Created env.dat with Test=123");
|
||||
}
|
||||
|
||||
// 输出系统启动-初始化完成后的时间
|
||||
TimeSpan uptime = DateTime.Now - Kernel.SystemStartTime;
|
||||
|
||||
// Console.WriteLine("System started: " + Kernel.SystemStartTime.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||
// Console.WriteLine("Current time: " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||
// Console.WriteLine();
|
||||
|
||||
// 格式化运行时间
|
||||
int days = uptime.Days;
|
||||
int hours = uptime.Hours;
|
||||
int minutes = uptime.Minutes;
|
||||
int seconds = uptime.Seconds;
|
||||
|
||||
Console.WriteLine($"System uptime: {days} days, {hours} hours, {minutes} minutes, {seconds} seconds");
|
||||
Console.WriteLine($"Total uptime: {uptime.TotalHours:F2} hours");
|
||||
|
||||
// 循环直到登录成功或退出
|
||||
while (true)
|
||||
{
|
||||
|
||||
@@ -226,7 +226,7 @@ namespace CMLeonOS
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
|
||||
Console.WriteLine("\rRestarting now! ");
|
||||
Console.WriteLine("\rRestarting now!");
|
||||
Sys.Power.Reboot();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Reference in New Issue
Block a user