From 22477f0eca904ec628ab59cd749f959af35c1439 Mon Sep 17 00:00:00 2001
From: Moli <linmolilin@gmail.com>
Date: 星期五, 15 四月 2022 10:15:52 +0800
Subject: [PATCH] 加入按配置使用的功能
---
WOLAwaken/Helper/SendUdpPack.cs | 33 +++++++++++++++++++++++++++++++--
1 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/WOLAwaken/Helper/SendUdpPack.cs b/WOLAwaken/Helper/SendUdpPack.cs
index 6398868..61e3d85 100644
--- a/WOLAwaken/Helper/SendUdpPack.cs
+++ b/WOLAwaken/Helper/SendUdpPack.cs
@@ -45,11 +45,40 @@
{
try
{
- localIpep = new IPEndPoint(IPAddress.Parse("192.168.2.111"), 53470); // 鏈満IP鍜岀洃鍚鍙e彿
+ var config = Helpers.Tool.GetSystemConfig().baseSysConfg;
+ var ipConfig = "127.0.0.1";
+ var portConfig = 53470;
+ var toIp = "255.255.255.255";
+ var toPort = 53490;
+ if (config != null)
+ {
+ if (!string.IsNullOrWhiteSpace(config.sendIp))
+ {
+ ipConfig = config.sendIp;
+ }
+ if (!string.IsNullOrWhiteSpace(config.sendPort))
+ {
+ int.TryParse(config.sendPort, out portConfig);
+ }
+ if (!string.IsNullOrWhiteSpace(config.toIp))
+ {
+ toIp = config.toIp;
+ }
+ if (!string.IsNullOrWhiteSpace(config.toPort))
+ {
+ int.TryParse(config.toPort, out toPort);
+ }
+ }
+ else
+ {
+ ipConfig = "127.0.0.1";
+ }
+ localIpep = new IPEndPoint(IPAddress.Parse(ipConfig), portConfig); // 鏈満IP鍜岀洃鍚鍙e彿
+
udpcSend = new UdpClient(localIpep);
byte[] sendbytes = data;
- IPEndPoint remoteIpep = new IPEndPoint(IPAddress.Parse("255.255.255.255"), 53490); // 鍙戦�佸埌鐨処P鍦板潃鍜岀鍙e彿
+ IPEndPoint remoteIpep = new IPEndPoint(IPAddress.Parse(toIp), toPort); // 鍙戦�佸埌鐨処P鍦板潃鍜岀鍙e彿
string str = "";
foreach (var a in sendbytes)
{
--
Gitblit v1.9.1