fix error with IP address in server
This commit is contained in:
@@ -20,13 +20,44 @@ namespace f_srv
|
||||
Option<IPAddress> ipOption = new("address", new[] { "--ip", "-i" })
|
||||
{
|
||||
Description = "IP адрес для прослушивания (по умолчанию: все интерфейсы)",
|
||||
DefaultValueFactory = parseResult => IPAddress.Any
|
||||
DefaultValueFactory = parseResult => IPAddress.Any,
|
||||
CustomParser = result =>
|
||||
{
|
||||
if (result.Tokens.Count != 1)
|
||||
{
|
||||
result.AddError("--address requires one argument");
|
||||
return IPAddress.Any;
|
||||
}
|
||||
|
||||
return IPAddress.Parse(result.Tokens.Single().Value);
|
||||
}
|
||||
};
|
||||
|
||||
Option<int> portOption = new("port", new[] { "--port", "-p" })
|
||||
{
|
||||
Description = "Порт для прослушивания (по умолчанию: 1771)",
|
||||
DefaultValueFactory = parseResult => 1771
|
||||
DefaultValueFactory = parseResult => 1771,
|
||||
CustomParser = result =>
|
||||
{
|
||||
if (!result.Tokens.Any())
|
||||
{
|
||||
return 1771;
|
||||
}
|
||||
|
||||
if (int.TryParse(result.Tokens.Single().Value, out var delay))
|
||||
{
|
||||
if (delay < 1)
|
||||
{
|
||||
result.AddError("Must be greater than 0");
|
||||
}
|
||||
return delay;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.AddError("Not an int.");
|
||||
return 0; // Ignored.
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var rootCommand = new RootCommand("Сервер для получения строк и отправки их в обратном порядке")
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"profiles": {
|
||||
"f-srv": {
|
||||
"commandName": "Project",
|
||||
"commandLineArgs": "--port 3113"
|
||||
"commandLineArgs": "--port 3113 -i 192.168.15.128"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user