This commit is contained in:
snltty
2025-02-18 15:17:32 +08:00
parent 3983f570a4
commit d1787bcd5e
9 changed files with 60 additions and 24 deletions

View File

@@ -174,6 +174,13 @@ namespace linker.messenger.serializer.memorypack
[MemoryPackIgnore]
public readonly UpdaterInfo info;
[MemoryPackInclude]
string Version => info.Version;
[MemoryPackInclude]
string[] Msg => info.Msg;
[MemoryPackInclude]
string DateTime => info.DateTime;
[MemoryPackInclude]
string MachineId => info.MachineId;
@@ -187,9 +194,9 @@ namespace linker.messenger.serializer.memorypack
long Current => info.Current;
[MemoryPackConstructor]
SerializableUpdateInfo(string machineId, UpdaterStatus status, long length, long current)
SerializableUpdateInfo(string version, string[] msg,string datetime,string machineId, UpdaterStatus status, long length, long current)
{
this.info = new UpdaterInfo { MachineId = machineId, Status = status, Length = length, Current = current };
this.info = new UpdaterInfo { Version=version, Msg=msg, DateTime=datetime, MachineId = machineId, Status = status, Length = length, Current = current };
}
public SerializableUpdateInfo(UpdaterInfo info)

View File

@@ -47,10 +47,6 @@ namespace linker.messenger.signin
public void PushNetworkEnabledBefore()
{
if (networdkEnabledTimes == 0)
{
NetworkFirstEnabledHandle?.Invoke();
}
NetworkEnabledHandleBefore?.Invoke();
}
/// <summary>

View File

@@ -1,6 +1,7 @@
using linker.libs;
using System.Collections.Concurrent;
using linker.messenger.signin;
using linker.libs.extends;
namespace linker.messenger.updater
{
@@ -33,7 +34,6 @@ namespace linker.messenger.updater
}
private void Init()
{
CheckTask();
UpdateTask();
updateInfo.Update();
}
@@ -93,6 +93,7 @@ namespace linker.messenger.updater
{
if (updateInfo.Updated)
{
await GetUpdateInfo();
updateInfo.MachineId = signInClientStore.Id;
string[] machines = subscribes.Where(c => c.Value.DiffLessEqual(15000)).Select(c => c.Key).ToArray();
if (machines.Length > 0)
@@ -101,7 +102,17 @@ namespace linker.messenger.updater
{
Connection = signInClientState.Connection,
MessengerId = (ushort)UpdaterMessengerIds.UpdateForward,
Payload = serializer.Serialize(new UpdaterClientInfo { ToMachines = machines, Info = updateInfo }),
Payload = serializer.Serialize(new UpdaterClientInfo
{
ToMachines = machines,
Info = new UpdaterInfo
{
Current = updateInfo.Current,
Length = updateInfo.Length,
Status = updateInfo.Status,
MachineId = updateInfo.MachineId
}
}),
});
}
Update(updateInfo);
@@ -117,17 +128,6 @@ namespace linker.messenger.updater
LoggerHelper.Instance.Info($"check update");
_ = GetUpdateInfo();
}
private void CheckTask()
{
TimerHelper.SetInterval(async () =>
{
if (updaterCommonTransfer.CheckUpdate)
{
await GetUpdateInfo();
}
return true;
}, () => updaterCommonTransfer.UpdateIntervalSeconds * 1000);
}
private async Task GetUpdateInfo()
{
if (updateInfo.Status > UpdaterStatus.Checked) return;

View File

@@ -212,6 +212,8 @@ namespace linker.messenger.updater
/// <param name="version"></param>
public void Confirm(UpdaterInfo updateInfo, string version)
{
if (string.IsNullOrWhiteSpace(version)) return;
TimerHelper.Async(async () =>
{
await DownloadUpdate(updateInfo, version);

View File

@@ -118,6 +118,14 @@ namespace linker.messenger.updater
UpdaterConfirmServerInfo confirm = serializer.Deserialize<UpdaterConfirmServerInfo>(connection.ReceiveRequestWrap.Payload.Span);
if (updaterServerStore.SecretKey == confirm.SecretKey)
{
if (string.IsNullOrWhiteSpace(confirm.Version))
{
confirm.Version = updaterServerTransfer.Get().Version;
}
if (string.IsNullOrWhiteSpace(confirm.Version))
{
return;
}
updaterServerTransfer.Confirm(confirm.Version);
}
}
@@ -166,6 +174,14 @@ namespace linker.messenger.updater
else machines = signCaching.Get(cache.GroupId).Where(c => c.MachineId == confirm.MachineId && c.GroupId == cache.GroupId);
confirm.SecretKey = string.Empty;
if (string.IsNullOrWhiteSpace(confirm.Version))
{
confirm.Version = updaterServerTransfer.Get().Version;
}
if (string.IsNullOrWhiteSpace(confirm.Version))
{
return;
}
var tasks = machines.Select(c =>
{
return messengerSender.SendOnly(new MessageRequestWrap

View File

@@ -1,13 +1,17 @@
namespace linker.messenger.updater
using linker.libs;
namespace linker.messenger.updater
{
public sealed class UpdaterServerTransfer
{
private UpdaterInfo updateInfo = new UpdaterInfo { Status = UpdaterStatus.Checked };
private readonly UpdaterHelper updaterHelper;
public UpdaterServerTransfer(UpdaterHelper updaterHelper)
private readonly IUpdaterCommonStore updaterCommonTransfer;
public UpdaterServerTransfer(UpdaterHelper updaterHelper, IUpdaterCommonStore updaterCommonTransfer)
{
this.updaterHelper = updaterHelper;
this.updaterCommonTransfer = updaterCommonTransfer;
CheckTask();
}
public UpdaterInfo Get()
@@ -22,5 +26,16 @@
updaterHelper.Confirm(updateInfo, version);
}
private void CheckTask()
{
TimerHelper.SetInterval(async () =>
{
if (updaterCommonTransfer.CheckUpdate)
{
await updaterHelper.GetUpdateInfo(updateInfo);
}
return true;
}, () => updaterCommonTransfer.UpdateIntervalSeconds * 1000);
}
}
}

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<project ver="10" name="linker.tray.win" libEmbed="true" icon="..\linker\favicon.ico" ui="win" output="linker.tray.win.exe" CompanyName="snltty" FileDescription="linker.tray.win" LegalCopyright="Copyright (C) snltty 2024" ProductName="linker.tray.win" InternalName="linker.install.win" FileVersion="0.0.0.202" ProductVersion="0.0.0.202" publishDir="/dist/" dstrip="false" local="false" ignored="false">
<project ver="10" name="linker.tray.win" libEmbed="true" icon="..\linker\favicon.ico" ui="win" output="linker.tray.win.exe" CompanyName="snltty" FileDescription="linker.tray.win" LegalCopyright="Copyright (C) snltty 2024" ProductName="linker.tray.win" InternalName="linker.install.win" FileVersion="0.0.0.203" ProductVersion="0.0.0.203" publishDir="/dist/" dstrip="false" local="false" ignored="false">
<file name="main.aardio" path="main.aardio" comment="main.aardio"/>
<folder name="资源文件" path="res" embed="true" local="false" ignored="false">
<file name="favicon.ico" path="res\favicon.ico" comment="res\favicon.ico"/>

Binary file not shown.

View File

@@ -1,5 +1,5 @@
v1.6.7
2025-02-18 11:10:37
2025-02-18 15:17:31
1. 修复首次启动网卡未启动bug
2. 自定义网卡名
3. 可禁用NAT