Skip to content

Commit

Permalink
SILKIT-1435: Fix local-domain connection with registry when using hos…
Browse files Browse the repository at this point in the history
…tnames in the listen URI and/or registry URI (#722)
  • Loading branch information
VDanielEdwards authored and GitHub Enterprise committed Nov 23, 2023
1 parent 576871f commit 5ee4f13
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 1 deletion.
1 change: 1 addition & 0 deletions SilKit/source/core/vasio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ if(MINGW)
endif()

add_silkit_test_to_executable(SilKitUnitTests SOURCES Test_VAsioConnection.cpp LIBS S_SilKitImpl I_SilKit_Core_Mock_Participant)
add_silkit_test_to_executable(SilKitUnitTests SOURCES Test_VAsioRegistry.cpp LIBS S_SilKitImpl)

add_silkit_test_to_executable(SilKitUnitTests SOURCES Test_VAsioSerdes.cpp LIBS S_SilKitImpl)
add_silkit_test_to_executable(SilKitUnitTests SOURCES Test_SerializedMessage.cpp LIBS S_SilKitImpl)
Expand Down
67 changes: 67 additions & 0 deletions SilKit/source/core/vasio/Test_VAsioRegistry.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/* Copyright (c) 2022 Vector Informatik GmbH
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */

#include "ConfigurationTestUtils.hpp"

#include "Uri.hpp"

#include "VAsioRegistry.hpp"

#include "gtest/gtest.h"
#include "gmock/gmock.h"


namespace {


TEST(Test_VAsioRegistry, check_start_listening)
{
using UriType = SilKit::Core::Uri::UriType;

auto configuration{SilKit::Config::MakeEmptyParticipantConfigurationImpl()};

{
SilKit::Core::VAsioRegistry vAsioRegistry{configuration};
SilKit::Core::Uri registryUri{vAsioRegistry.StartListening("silkit://localhost:0")};
ASSERT_EQ(registryUri.Type(), UriType::Tcp);
ASSERT_EQ(registryUri.Host(), "localhost");
ASSERT_NE(registryUri.Port(), 0);
}

{
SilKit::Core::VAsioRegistry vAsioRegistry{configuration};
SilKit::Core::Uri registryUri{vAsioRegistry.StartListening("silkit://0.0.0.0:0")};
ASSERT_EQ(registryUri.Type(), UriType::Tcp);
ASSERT_EQ(registryUri.Host(), "0.0.0.0");
ASSERT_NE(registryUri.Port(), 0);
}

{
SilKit::Core::VAsioRegistry vAsioRegistry{configuration};
SilKit::Core::Uri registryUri{vAsioRegistry.StartListening("silkit://127.0.0.1:0")};
ASSERT_EQ(registryUri.Type(), UriType::Tcp);
ASSERT_EQ(registryUri.Host(), "127.0.0.1");
ASSERT_NE(registryUri.Port(), 0);
}
}


} // namespace
2 changes: 1 addition & 1 deletion SilKit/source/core/vasio/VAsioRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ auto VAsioRegistry::StartListening(const std::string& listenUri) -> std::string
// Resolve the configured hostname and accept on the given port:
auto tcpHostPort = _connection.AcceptTcpConnectionsOn(uri.Host(), uri.Port());
// Update the URI to the actually used address and port:
uri = Uri{tcpHostPort.first, tcpHostPort.second};
uri = Uri{uri.Host(), tcpHostPort.second};

hasTcpSocket = true;
}
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Fixed
~~~~~

- The LIN demo does not skip the first entry (sending frame 16) on all but the first iteration through the schedule anymore.
- The name of the domain-socket used by the registry will use the hostname passed in the listen URI, not the resolved IP address (if any), for generating the name of the domain-socket.


[4.0.39] - 2023-11-14
Expand Down

0 comments on commit 5ee4f13

Please sign in to comment.