Files
MoShiro/backend/fleet/src/Fleet.Rpc/PeerMethods.cs
T
justme ad5efc62ff agent: unify listening and dialing with directed mutual measurements
Replace Probe with Agent across node runtime, Fleet contracts, backend state, API and storage. Report incoming sessions and outgoing link health through each Agent uplink, and retain directed link controls and retry.

Update protocol fixtures and end-to-end coverage for the unified model; accept requested cancellation during the Fleet timeout test cleanup.
2026-10-21 11:55:36 +08:00

53 lines
1.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Text.Json.Serialization;
namespace Fleet.Rpc;
/// <summary>
/// 节点间点对点会话的握手(拨号方 → 监听方,TLS 帧)。除了签名认证,双方各生成一个临时 ECDH 密钥,
/// 经过 HKDF 派生出数据面使用的 <c>session_id</c> 与 <c>session_key</c>(所以不需要单独的“下发密钥”方法)。
/// </summary>
public static class PeerMethods
{
public const string Challenge = "fleet.peer.challenge";
public const string Auth = "fleet.peer.auth";
}
public sealed class PeerChallengeParams
{
[JsonPropertyName("nonce")]
public string Nonce { get; set; } = "";
/// <summary>服务端(监听方)的临时 ECDH 公钥(SPKI,base64)。</summary>
[JsonPropertyName("ecdh_pub")]
public string EcdhPublicKey { get; set; } = "";
}
public sealed class PeerAuthParams
{
[JsonPropertyName("peer_id")]
public string PeerId { get; set; } = "";
/// <summary>发起方的临时 ECDH 公钥(SPKI,base64)。</summary>
[JsonPropertyName("ecdh_pub")]
public string EcdhPublicKey { get; set; } = "";
/// <summary>对 <c>fleet|v1|peer|{peer_id}|{nonce}|{client_ecdh_pub}|{server_ecdh_pub}</c> 的签名(base64)。</summary>
[JsonPropertyName("signature")]
public string Signature { get; set; } = "";
/// <summary>发起方的程序版本(可选,只用于展示)。</summary>
[JsonPropertyName("version")]
public string? Version { get; set; }
}
public sealed class PeerAuthResult
{
[JsonPropertyName("session_id")]
public string SessionId { get; set; } = "";
}
[JsonSerializable(typeof(PeerChallengeParams))]
[JsonSerializable(typeof(PeerAuthParams))]
[JsonSerializable(typeof(PeerAuthResult))]
public sealed partial class PeerRpcContext : JsonSerializerContext;