fix: restore windows agent https port contract

This commit is contained in:
sladro 2026-03-27 11:07:16 +08:00
parent bc5e980326
commit 3b4febda6b
7 changed files with 11 additions and 11 deletions

View File

@ -8,7 +8,7 @@ public sealed class AgentOptions
public string BindAddress { get; set; } = "0.0.0.0";
public int Port { get; set; }
public int HttpsPort { get; set; }
public int WebSocketFrameFlushMilliseconds { get; set; }

View File

@ -17,7 +17,7 @@ public static class AgentOptionsServiceCollectionExtensions
{
options.DataRoot = effectiveOptions.DataRoot;
options.BindAddress = effectiveOptions.BindAddress;
options.Port = effectiveOptions.Port;
options.HttpsPort = effectiveOptions.HttpsPort;
options.WebSocketFrameFlushMilliseconds = effectiveOptions.WebSocketFrameFlushMilliseconds;
options.RingBufferLineLimit = effectiveOptions.RingBufferLineLimit;
})

View File

@ -13,9 +13,9 @@ public sealed class AgentOptionsValidator : IValidateOptions<AgentOptions>
failures.Add("Agent:DataRoot must be configured.");
}
if (options.Port is < 1 or > 65535)
if (options.HttpsPort is < 1 or > 65535)
{
failures.Add("Agent:Port must be between 1 and 65535.");
failures.Add("Agent:HttpsPort must be between 1 and 65535.");
}
if (options.WebSocketFrameFlushMilliseconds <= 0)

View File

@ -4,7 +4,7 @@ using TermRemoteCtl.Agent.Configuration;
var builder = WebApplication.CreateBuilder(args);
var agentOptions = builder.Services.AddAgentOptions(builder.Configuration);
builder.WebHost.UseUrls($"http://{agentOptions.BindAddress}:{agentOptions.Port}");
builder.WebHost.UseUrls($"http://{agentOptions.BindAddress}:{agentOptions.HttpsPort}");
var app = builder.Build();
agentOptions = app.Services.GetRequiredService<IOptions<AgentOptions>>().Value;

View File

@ -2,7 +2,7 @@
"Agent": {
"DataRoot": "C:\\ProgramData\\TermRemoteCtl",
"BindAddress": "0.0.0.0",
"Port": 9443,
"HttpsPort": 9443,
"WebSocketFrameFlushMilliseconds": 33,
"RingBufferLineLimit": 4000
}

View File

@ -14,7 +14,7 @@ public class AgentOptionsPipelineTests
var configuration = BuildConfiguration(new Dictionary<string, string?>
{
["Agent:BindAddress"] = "127.0.0.1",
["Agent:Port"] = "9443",
["Agent:HttpsPort"] = "9443",
["Agent:WebSocketFrameFlushMilliseconds"] = "33",
["Agent:RingBufferLineLimit"] = "4000"
});
@ -33,17 +33,17 @@ public class AgentOptionsPipelineTests
}
[Theory]
[InlineData("0", "33", "Port")]
[InlineData("0", "33", "HttpsPort")]
[InlineData("9443", "0", "WebSocketFrameFlushMilliseconds")]
public void ResolveOptions_Fails_When_Config_Is_Invalid(
string port,
string httpsPort,
string flushMilliseconds,
string expectedFailure)
{
var configuration = BuildConfiguration(new Dictionary<string, string?>
{
["Agent:BindAddress"] = "127.0.0.1",
["Agent:Port"] = port,
["Agent:HttpsPort"] = httpsPort,
["Agent:WebSocketFrameFlushMilliseconds"] = flushMilliseconds,
["Agent:RingBufferLineLimit"] = "4000"
});

View File

@ -11,7 +11,7 @@ public class AgentOptionsValidatorTests
{
DataRoot = "",
BindAddress = "0.0.0.0",
Port = 9443
HttpsPort = 9443
};
var validator = new AgentOptionsValidator();