84 lines
2.6 KiB
C#
84 lines
2.6 KiB
C#
using Fleet.Core;
|
|
using Fleet.Server;
|
|
|
|
namespace MoShiro.Backend.Application;
|
|
|
|
public sealed record AgentRecord(
|
|
NodeId Id,
|
|
string Name,
|
|
NodeStatus Status,
|
|
byte[] PublicKey,
|
|
byte[] TlsSpki,
|
|
string PublicHost,
|
|
int ProbeTcpPort,
|
|
IReadOnlyList<int> ProbeUdpPorts,
|
|
IReadOnlyList<string> Labels,
|
|
bool PublicVisible,
|
|
IReadOnlyList<string> Kinds,
|
|
string? AgentVersion,
|
|
string? LocalLimitsJson,
|
|
long TaskVersion,
|
|
long AppliedTaskVersion,
|
|
string? RejectedJson,
|
|
long CreatedAtMs,
|
|
long? LastSeenAtMs,
|
|
long RowVersion,
|
|
string Ipv6Host = "",
|
|
bool Ipv6Supported = false,
|
|
string? Ipv6DiagnosticsJson = null,
|
|
bool PublicHostManual = false,
|
|
bool Ipv6HostManual = false,
|
|
IReadOnlyList<string>? ReportedAddresses = null);
|
|
|
|
/// <summary>管理员可以修改的字段(merge-patch 语义:为 null 的字段不改)。</summary>
|
|
public sealed class AgentPatch
|
|
{
|
|
public string? Name { get; init; }
|
|
|
|
public IReadOnlyList<string>? Labels { get; init; }
|
|
|
|
public string? PublicHost { get; init; }
|
|
|
|
public string? Ipv6Host { get; init; }
|
|
|
|
/// <summary>为 true:撤销手填,回到自动识别(<see cref="PublicHost"/> 同时给出则忽略)。</summary>
|
|
public bool? PublicHostAuto { get; init; }
|
|
|
|
public bool? Ipv6HostAuto { get; init; }
|
|
|
|
public bool? PublicVisible { get; init; }
|
|
}
|
|
|
|
/// <summary>来自 <c>fleet.hello</c> 的信息。</summary>
|
|
public sealed record AgentHello(
|
|
IReadOnlyList<string> Kinds,
|
|
string? AgentVersion,
|
|
string? LocalLimitsJson,
|
|
byte[]? TlsSpki,
|
|
int? ProbeTcpPort,
|
|
IReadOnlyList<int>? ProbeUdpPorts,
|
|
bool Ipv6Supported = false,
|
|
string? Ipv6DiagnosticsJson = null,
|
|
IReadOnlyList<string>? Addresses = null);
|
|
|
|
/// <summary>注册之后 MoShiro 的补充:公开地址和端口。</summary>
|
|
public sealed record AgentEnrollment(string PublicHost, int ProbeTcpPort, IReadOnlyList<int> ProbeUdpPorts, IReadOnlyList<string> Kinds);
|
|
|
|
public sealed record JoinTokenInfo(
|
|
string Id,
|
|
string? Note,
|
|
IReadOnlyList<string> Labels,
|
|
bool AutoApprove,
|
|
int MaxUses,
|
|
int Uses,
|
|
long ExpiresAtMs,
|
|
long? RevokedAtMs,
|
|
long CreatedAtMs,
|
|
string Kind = "");
|
|
|
|
/// <summary>
|
|
/// <see cref="PublicKey"/> 是连 Backend 的身份公钥,<see cref="PeerPublicKey"/> 是对等面(连 Agent)的公钥,两把是节点自己生成的独立密钥;
|
|
/// Agent 的 <c>peers</c> 里放的是后者。
|
|
/// </summary>
|
|
public sealed record ProbeRecord(string Id, string Name, byte[] PublicKey, long CreatedAtMs, long? RevokedAtMs, string? Ipv6DiagnosticsJson = null, byte[]? PeerPublicKey = null);
|