feat: 使用静态arp处理通信

This commit is contained in:
2025-07-18 13:16:07 +08:00
parent e9ad1f0256
commit 9af2d3e87e
6 changed files with 372 additions and 75 deletions

View File

@@ -33,6 +33,10 @@ public class NetConfigController : ControllerBase
try
{
var netConfig = new NetConfig(BOARD_IP, BOARD_PORT, 0);
if (!(await netConfig.Init()))
{
throw new Exception($"无法配置ARP");
}
var result = await netConfig.GetHostIP();
if (!result.IsSuccessful)
@@ -63,6 +67,10 @@ public class NetConfigController : ControllerBase
try
{
var netConfig = new NetConfig(BOARD_IP, BOARD_PORT, 0);
if (!(await netConfig.Init()))
{
throw new Exception($"无法配置ARP");
}
var result = await netConfig.GetBoardIP();
if (!result.IsSuccessful)
@@ -93,6 +101,10 @@ public class NetConfigController : ControllerBase
try
{
var netConfig = new NetConfig(BOARD_IP, BOARD_PORT, 0);
if (!(await netConfig.Init()))
{
throw new Exception($"无法配置ARP");
}
var result = await netConfig.GetHostMAC();
if (!result.IsSuccessful)
@@ -123,6 +135,10 @@ public class NetConfigController : ControllerBase
try
{
var netConfig = new NetConfig(BOARD_IP, BOARD_PORT, 0);
if (!(await netConfig.Init()))
{
throw new Exception($"无法配置ARP");
}
var result = await netConfig.GetBoardMAC();
if (!result.IsSuccessful)
@@ -153,6 +169,10 @@ public class NetConfigController : ControllerBase
try
{
var netConfig = new NetConfig(BOARD_IP, BOARD_PORT, 0);
if (!(await netConfig.Init()))
{
throw new Exception($"无法配置ARP");
}
var hostIPResult = await netConfig.GetHostIP();
var boardIPResult = await netConfig.GetBoardIP();
@@ -237,6 +257,10 @@ public class NetConfigController : ControllerBase
{
// 创建网络配置客户端
var netConfig = new NetConfig(BOARD_IP, BOARD_PORT, 0);
if (!(await netConfig.Init()))
{
throw new Exception($"无法配置ARP");
}
var result = await netConfig.SetHostIP(hostIpAddress);
if (!result.IsSuccessful)
@@ -276,6 +300,10 @@ public class NetConfigController : ControllerBase
{
// 创建网络配置客户端
var netConfig = new NetConfig(BOARD_IP, BOARD_PORT, 0);
if (!(await netConfig.Init()))
{
throw new Exception($"无法配置ARP");
}
var result = await netConfig.SetBoardIP(newIpAddress);
if (!result.IsSuccessful)
@@ -316,6 +344,10 @@ public class NetConfigController : ControllerBase
{
// 创建网络配置客户端
var netConfig = new NetConfig(BOARD_IP, BOARD_PORT, 0);
if (!(await netConfig.Init()))
{
throw new Exception($"无法配置ARP");
}
var result = await netConfig.SetHostMAC(macBytes);
if (!result.IsSuccessful)
@@ -367,6 +399,10 @@ public class NetConfigController : ControllerBase
return StatusCode(StatusCodes.Status500InternalServerError, "无法获取本机IP地址");
var netConfig = new NetConfig(BOARD_IP, BOARD_PORT, 0);
if (!(await netConfig.Init()))
{
throw new Exception($"无法配置ARP");
}
var result = await netConfig.SetHostIP(ip);
if (!result.IsSuccessful)
@@ -411,6 +447,10 @@ public class NetConfigController : ControllerBase
// 创建网络配置客户端
var netConfig = new NetConfig(BOARD_IP, BOARD_PORT, 0);
if (!(await netConfig.Init()))
{
throw new Exception($"无法配置ARP");
}
var result = await netConfig.SetHostMAC(macBytes);
if (!result.IsSuccessful)
@@ -451,6 +491,10 @@ public class NetConfigController : ControllerBase
{
// 创建网络配置客户端
var netConfig = new NetConfig(BOARD_IP, BOARD_PORT, 0);
if (!(await netConfig.Init()))
{
throw new Exception($"无法配置ARP");
}
var result = await netConfig.SetBoardMAC(macBytes);
if (!result.IsSuccessful)