Add deprecation notice

This commit is contained in:
badaix 2025-01-26 22:37:59 +01:00
parent 23107d62f9
commit 054706e608
5 changed files with 44 additions and 13 deletions

View file

@ -1,5 +1,21 @@
# Snapcast changelog
## Version 0.32.0
### Features
- Client: Add support for (secure-) websockets (Issue #1325)
### Bugfixes
- Fix typo in documentation (PR #1333)
### General
- Client: Command line arguments '--host' and '--port' are deprecated
_Johannes Pohl <snapcast@badaix.de> Thu, 23 Jan 2025 00:13:37 +0200_
## Version 0.31.0
### Features

View file

@ -143,8 +143,8 @@ int main(int argc, char** argv)
auto helpSwitch = op.add<Switch>("", "help", "Produce help message");
auto groffSwitch = op.add<Switch, Attribute::hidden>("", "groff", "Produce groff message");
auto versionSwitch = op.add<Switch>("v", "version", "Show version number");
op.add<Value<string>>("h", "host", "(deprecated, use [url]) Server hostname or ip address", "", &settings.server.host);
op.add<Value<size_t>>("p", "port", "(deprecated, use [url]) Server port", 1704, &settings.server.port);
auto host_opt = op.add<Value<string>>("h", "host", "(deprecated, use [url]) Server hostname or ip address", "", &settings.server.host);
auto port_opt = op.add<Value<size_t>>("p", "port", "(deprecated, use [url]) Server port", 1704, &settings.server.port);
op.add<Value<size_t>>("i", "instance", "Instance id when running multiple instances on the same host", 1, &settings.instance);
op.add<Value<string>>("", "hostID", "Unique host id, default is MAC address", "", &settings.host_id);
auto server_cert_opt = op.add<Implicit<std::filesystem::path>>("", "server-cert", "Verify server with certificate", "default certificates");
@ -310,13 +310,36 @@ int main(int argc, char** argv)
else
throw SnapException("Invalid log sink: " + settings.logging.sink);
if (!op.unknown_options().empty())
{
throw SnapException("Unknown command line argument: '" + op.unknown_options().front() + "'");
}
if (host_opt->is_set() || port_opt->is_set())
{
LOG(WARNING, LOG_TAG) << "Options '--" << host_opt->long_name() << "' and '--" << port_opt->long_name()
<< "' are deprecated. Please add the server URI as last command line argument\n";
}
if (!op.non_option_args().empty())
{
streamreader::StreamUri uri(op.non_option_args().front());
StreamUri uri;
try
{
uri.parse(op.non_option_args().front());
}
catch (...)
{
throw SnapException("Invalid URI - expected format: \"<scheme>://<host or IP>[:port]\", with 'scheme' on of 'tcp', 'ws' or 'wss'");
}
if ((uri.scheme != "tcp") && (uri.scheme != "ws") && (uri.scheme != "wss"))
throw SnapException("Protocol must be one of 'tcp', 'ws' or 'wss'");
settings.server.host = uri.host;
settings.server.protocol = uri.scheme;
if (uri.port.has_value())
settings.server.port = uri.port.value();
else if (settings.server.protocol == "tcp")
settings.server.port = 1704;
else if (settings.server.protocol == "ws")
settings.server.port = 1780;
else if (settings.server.protocol == "wss")

View file

@ -34,8 +34,6 @@ namespace strutils = utils::string;
static constexpr auto LOG_TAG = "StreamUri";
namespace streamreader
{
StreamUri::StreamUri(const std::string& uri)
{
@ -179,5 +177,3 @@ bool StreamUri::operator==(const StreamUri& other) const
return (other.scheme == scheme) && (other.host == host) && (other.port == port) && (other.path == path) && (other.query == query) &&
(other.fragment == fragment);
}
} // namespace streamreader

View file

@ -30,13 +30,12 @@
using json = nlohmann::json;
namespace streamreader
{
/// URI with the general format:
/// scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]
struct StreamUri
{
/// c'tor
StreamUri() = default;
/// c'tor construct from string @p uri
explicit StreamUri(const std::string& uri);
@ -79,5 +78,3 @@ struct StreamUri
/// @return true if @p other is equal to this
bool operator==(const StreamUri& other) const;
};
} // namespace streamreader

View file

@ -224,7 +224,6 @@ TEST_CASE("JWT")
TEST_CASE("Uri")
{
using namespace streamreader;
StreamUri uri("pipe:///tmp/snapfifo?name=default&codec=flac");
REQUIRE(uri.scheme == "pipe");
REQUIRE(uri.path == "/tmp/snapfifo");