diff --git a/changelog.md b/changelog.md index 1ae2bd99..6d41052e 100644 --- a/changelog.md +++ b/changelog.md @@ -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 Thu, 23 Jan 2025 00:13:37 +0200_ + ## Version 0.31.0 ### Features diff --git a/client/snapclient.cpp b/client/snapclient.cpp index d67d05ad..281c3f5f 100644 --- a/client/snapclient.cpp +++ b/client/snapclient.cpp @@ -143,8 +143,8 @@ int main(int argc, char** argv) auto helpSwitch = op.add("", "help", "Produce help message"); auto groffSwitch = op.add("", "groff", "Produce groff message"); auto versionSwitch = op.add("v", "version", "Show version number"); - op.add>("h", "host", "(deprecated, use [url]) Server hostname or ip address", "", &settings.server.host); - op.add>("p", "port", "(deprecated, use [url]) Server port", 1704, &settings.server.port); + auto host_opt = op.add>("h", "host", "(deprecated, use [url]) Server hostname or ip address", "", &settings.server.host); + auto port_opt = op.add>("p", "port", "(deprecated, use [url]) Server port", 1704, &settings.server.port); op.add>("i", "instance", "Instance id when running multiple instances on the same host", 1, &settings.instance); op.add>("", "hostID", "Unique host id, default is MAC address", "", &settings.host_id); auto server_cert_opt = op.add>("", "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: \"://[: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") diff --git a/common/stream_uri.cpp b/common/stream_uri.cpp index d3409d0a..350abf25 100644 --- a/common/stream_uri.cpp +++ b/common/stream_uri.cpp @@ -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 diff --git a/common/stream_uri.hpp b/common/stream_uri.hpp index fce5bbc4..ebeb94bd 100644 --- a/common/stream_uri.hpp +++ b/common/stream_uri.hpp @@ -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 diff --git a/test/test_main.cpp b/test/test_main.cpp index 9023403c..8af0a863 100644 --- a/test/test_main.cpp +++ b/test/test_main.cpp @@ -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");