Skip to content

Commit 93dab0d

Browse files
Merge branch 'master' into bcp-008-01
2 parents b24ce69 + 21d1a81 commit 93dab0d

24 files changed

+856
-900
lines changed

.github/workflows/build-test.yml

+7-572
Large diffs are not rendered by default.

.github/workflows/src/build-test.yml

+5-84
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,28 @@ on: [pull_request, push]
1010
env:
1111
SECRET_GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }}
1212
SECRET_RESULTS_SHEET_ID: ${{ secrets.RESULTS_SHEET_ID }}
13-
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
1413
jobs:
1514
build_and_test:
1615
name: '${{ matrix.os }}: build and test (install mdns: ${{ matrix.install_mdns }}, use conan: ${{ matrix.use_conan }}, force cpprest asio: ${{ matrix.force_cpprest_asio }}, dns-sd mode: ${{ matrix.dns_sd_mode}}, enable_authorization: ${{ matrix.enable_authorization }})'
1716
runs-on: ${{ matrix.os }}
1817
strategy:
1918
fail-fast: false
2019
matrix:
21-
os: [ubuntu-20.04, macos-11, windows-2019]
20+
os: [ubuntu-20.04, windows-2019]
2221
install_mdns: [false, true]
2322
use_conan: [true]
2423
force_cpprest_asio: [false]
2524
dns_sd_mode: [multicast, unicast]
2625
enable_authorization: [false, true]
2726
exclude:
2827
# install_mdns is only meaningful on Linux
29-
- os: macos-11
30-
enable_authorization: false
3128
- os: windows-2019
3229
enable_authorization: false
3330
- os: ubuntu-20.04
3431
enable_authorization: false
35-
- os: macos-11
36-
install_mdns: true
3732
- os: windows-2019
3833
install_mdns: true
3934
# for now, unicast DNS-SD tests are only implemented on Linux
40-
- os: macos-11
41-
dns_sd_mode: unicast
4235
- os: windows-2019
4336
dns_sd_mode: unicast
4437
# for now, exclude unicast DNS-SD with mDNSResponder due to
@@ -112,81 +105,9 @@ jobs:
112105
113106
@import build-and-test
114107

115-
build_and_test_ubuntu_14:
116-
name: '${{ matrix.os }}: build and test (install mdns: ${{ matrix.install_mdns }}, use conan: ${{ matrix.use_conan }}, force cpprest asio: ${{ matrix.force_cpprest_asio }}, dns-sd mode: ${{ matrix.dns_sd_mode}}, enable_authorization: ${{ matrix.enable_authorization }})'
117-
runs-on: ubuntu-20.04
118-
container:
119-
image: ubuntu:14.04
120-
strategy:
121-
fail-fast: false
122-
matrix:
123-
os: [ubuntu-14.04]
124-
install_mdns: [true]
125-
use_conan: [false]
126-
force_cpprest_asio: [false]
127-
dns_sd_mode: [multicast]
128-
enable_authorization: [true]
129-
130-
steps:
131-
- uses: actions/checkout@v3
132-
133-
- name: set environment variables
134-
shell: bash
135-
run: |
136-
if [[ "${{ runner.os }}" == "Linux" ]]; then
137-
if [[ "${{ matrix.install_mdns }}" == "true" ]]; then
138-
echo "BUILD_NAME=${{ matrix.os }}_mdns_${{ matrix.dns_sd_mode }}" >> $GITHUB_ENV
139-
else
140-
echo "BUILD_NAME=${{ matrix.os }}_avahi_${{ matrix.dns_sd_mode }}" >> $GITHUB_ENV
141-
fi
142-
elif [[ "${{ matrix.force_cpprest_asio }}" == "true" ]]; then
143-
echo "BUILD_NAME=${{ matrix.os }}_asio" >> $GITHUB_ENV
144-
else
145-
echo "BUILD_NAME=${{ matrix.os }}" >> $GITHUB_ENV
146-
fi
147-
GITHUB_COMMIT=`echo "${{ github.sha }}" | cut -c1-7`
148-
echo "GITHUB_COMMIT=$GITHUB_COMMIT" >> $GITHUB_ENV
149-
# github.workspace points to the host path not the docker path, the home directory defaults to the workspace directory
150-
echo "GITHUB_WORKSPACE=`pwd`" >> $GITHUB_ENV
151-
cd ..
152-
echo "RUNNER_WORKSPACE=`pwd`" >> $GITHUB_ENV
153-
154-
- name: install build tools
155-
run: |
156-
apt-get update -q
157-
apt-get install -y software-properties-common
158-
apt-get --allow-unauthenticated update -q
159-
apt-get --allow-unauthenticated install -y curl g++ git make patch zlib1g-dev libssl-dev bsdmainutils dnsutils unzip
160-
# ubuntu-14.04 ca-certificates are out of date
161-
git config --global http.sslVerify false
162-
# build and install openssl
163-
curl -OsSk https://openssl.org/source/old/1.1.1/openssl-1.1.1v.tar.gz
164-
tar xzf openssl-1.1.1v.tar.gz
165-
cd openssl-1.1.1v
166-
./config --prefix=/usr/local/custom-openssl --libdir=lib --openssldir=/etc/ssl
167-
make -j1 depend
168-
make -j8
169-
make install_sw
170-
cd ..
171-
# install ffi.h, which is required for python build
172-
apt install libffi-dev
173-
# build and install python
174-
curl -sSk https://www.python.org/ftp/python/3.11.5/Python-3.11.5.tar.xz | tar -xJ
175-
cd Python-3.11.5
176-
./configure -C --with-openssl=/usr/local/custom-openssl --with-openssl-rpath=auto
177-
make -j8
178-
make install
179-
update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.11 3
180-
ln -s /usr/local/bin/python3.11 /usr/bin/python
181-
curl -sS https://bootstrap.pypa.io/pip/3.6/get-pip.py | python
182-
curl -sS https://nodejs.org/dist/v12.16.2/node-v12.16.2-linux-x64.tar.xz | tar -xJ
183-
echo "`pwd`/node-v12.16.2-linux-x64/bin" >> $GITHUB_PATH
184-
185-
@import build-and-test
186-
187108
make_badges:
188109
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
189-
needs: [build_and_test, build_and_test_ubuntu_14]
110+
needs: [build_and_test]
190111
runs-on: ubuntu-20.04
191112
steps:
192113
- uses: actions/checkout@v3
@@ -199,14 +120,14 @@ jobs:
199120
echo "GITHUB_WORKSPACE=${{ github.workspace }}" >> $GITHUB_ENV
200121
echo "RUNNER_WORKSPACE=${{ runner.workspace }}" >> $GITHUB_ENV
201122
202-
- uses: actions/download-artifact@v2.0
123+
- uses: actions/download-artifact@v4
203124
with:
204125
path: ${{ runner.workspace }}/artifacts
205126

206127
- name: make badges
207128
run: |
208-
# combine badges from all builds, exclude macos-11
209-
${{ github.workspace }}/Sandbox/make_badges.sh ${{ github.workspace }} ${{ runner.workspace }}/artifacts macos-11_auth macos-11_noauth
129+
# combine badges from all builds, exclude macos-13
130+
${{ github.workspace }}/Sandbox/make_badges.sh ${{ github.workspace }} ${{ runner.workspace }}/artifacts macos-13_auth macos-13_noauth
210131
211132
# force push to github onto an orphan 'badges' branch
212133
cd ${{ github.workspace }}

.github/workflows/src/save-results.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
export SHEET=https://docs.google.com/spreadsheets/d/${{ env.SECRET_RESULTS_SHEET_ID }}
77
python nmos-testing/utilities/run-test-suites/gsheetsImport/resultsImporter.py --credentials ${{ env.GDRIVE_CREDENTIALS }} --sheet "$SHEET" --insert --json nmos-testing/results/${{ env.GITHUB_COMMIT }}-*.json || echo "upload failed"
88
9-
- uses: actions/upload-artifact@v1
9+
- uses: actions/upload-artifact@v4
1010
with:
1111
name: ${{ env.BUILD_NAME }}_badges
1212
path: ${{ runner.workspace }}/nmos-testing/badges
1313

14-
- uses: actions/upload-artifact@v1
14+
- uses: actions/upload-artifact@v4
1515
with:
1616
name: ${{ env.BUILD_NAME }}_results
1717
path: ${{ runner.workspace }}/nmos-testing/results

Development/cmake/NmosCppTest.cmake

+2
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,13 @@ set(NMOS_CPP_TEST_NMOS_TEST_SOURCES
4747
nmos/test/did_sdid_test.cpp
4848
nmos/test/event_type_test.cpp
4949
nmos/test/json_validator_test.cpp
50+
nmos/test/jwt_generator_test.cpp
5051
nmos/test/jwt_validation_test.cpp
5152
nmos/test/paging_utils_test.cpp
5253
nmos/test/query_api_test.cpp
5354
nmos/test/sdp_test_utils.cpp
5455
nmos/test/sdp_utils_test.cpp
56+
nmos/test/slog_test.cpp
5557
nmos/test/system_resources_test.cpp
5658
nmos/test/video_jxsv_test.cpp
5759
)

Development/cpprest/json_ops.h

+16-12
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,7 @@ namespace web
5151
return !(lhs == rhs);
5252
}
5353

54-
inline bool operator<(const web::json::object& lhs, const web::json::object& rhs)
55-
{
56-
using std::begin;
57-
using std::end;
58-
return std::lexicographical_compare(begin(lhs), end(lhs), begin(rhs), end(rhs));
59-
}
54+
inline bool operator<(const web::json::object& lhs, const web::json::object& rhs);
6055

6156
inline bool operator>(const web::json::object& lhs, const web::json::object& rhs)
6257
{
@@ -87,12 +82,7 @@ namespace web
8782
return !(lhs == rhs);
8883
}
8984

90-
inline bool operator<(const web::json::array& lhs, const web::json::array& rhs)
91-
{
92-
using std::begin;
93-
using std::end;
94-
return std::lexicographical_compare(begin(lhs), end(lhs), begin(rhs), end(rhs));
95-
}
85+
inline bool operator<(const web::json::array& lhs, const web::json::array& rhs);
9686

9787
inline bool operator>(const web::json::array& lhs, const web::json::array& rhs)
9888
{
@@ -142,6 +132,20 @@ namespace web
142132
{
143133
return !(lhs < rhs);
144134
}
135+
136+
inline bool operator<(const web::json::array& lhs, const web::json::array& rhs)
137+
{
138+
using std::begin;
139+
using std::end;
140+
return std::lexicographical_compare(begin(lhs), end(lhs), begin(rhs), end(rhs));
141+
}
142+
143+
inline bool operator<(const web::json::object& lhs, const web::json::object& rhs)
144+
{
145+
using std::begin;
146+
using std::end;
147+
return std::lexicographical_compare(begin(lhs), end(lhs), begin(rhs), end(rhs));
148+
}
145149
}
146150
}
147151

Development/mdns/service_discovery_impl.cpp

+30-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
#include "mdns/service_discovery_impl.h"
22

3+
#if defined(_WIN32)
4+
#include <ws2tcpip.h>
5+
#include <iphlpapi.h>
6+
#pragma comment(lib, "IPHLPAPI.lib")
7+
#else
8+
#include <net/if.h>
9+
#endif
310
#include <boost/asio/ip/address.hpp>
411
#include <boost/algorithm/string/predicate.hpp>
512
#include <boost/algorithm/string/erase.hpp>
@@ -25,6 +32,24 @@ namespace mdns_details
2532
return kDNSServiceInterfaceIndexLocalOnly == interfaceIndex ? kDNSServiceInterfaceIndexAny : interfaceIndex;
2633
}
2734

35+
static inline std::string get_interface_name(std::uint32_t interfaceIndex)
36+
{
37+
char if_name[IF_NAMESIZE];
38+
39+
if (kDNSServiceInterfaceIndexAny == interfaceIndex) return "any interface";
40+
// hm, on Windows, if_indextoname returns a name that is neither the AdapterName nor the FriendlyName from GetAdaptersAddresses
41+
if (0 != if_indextoname(interfaceIndex, if_name)) return if_name;
42+
return "unknown interface";
43+
}
44+
45+
struct if_name_manip
46+
{
47+
std::uint32_t i = kDNSServiceInterfaceIndexAny;
48+
explicit if_name_manip(std::uint32_t i) : i(i) {}
49+
friend std::ostream& operator<<(std::ostream& os, const if_name_manip& manip) { return os << manip.i << " (" << get_interface_name(manip.i) << ")"; }
50+
};
51+
static inline if_name_manip put_interface_id(std::uint32_t interface_id) { return if_name_manip{ interface_id }; }
52+
2853
struct browse_context
2954
{
3055
// browse in-flight state
@@ -52,7 +77,7 @@ namespace mdns_details
5277
{
5378
const browse_result result{ serviceName, regtype, replyDomain, make_interface_id(interfaceIndex) };
5479

55-
slog::log<slog::severities::more_info>(impl->gate, SLOG_FLF) << "After DNSServiceBrowse, DNSServiceBrowseReply got service: " << result.name << " for regtype: " << result.type << " domain: " << result.domain << " on interface: " << result.interface_id;
80+
slog::log<slog::severities::more_info>(impl->gate, SLOG_FLF) << "After DNSServiceBrowse, DNSServiceBrowseReply got service: " << result.name << " for regtype: " << result.type << " domain: " << result.domain << " on interface: " << put_interface_id(result.interface_id);
5681

5782
impl->had_enough = impl->handler(result);
5883
}
@@ -81,8 +106,7 @@ namespace mdns_details
81106
const auto latest_timeout = now + latest_timeout_;
82107
const auto earliest_timeout = now + earliest_timeout_;
83108

84-
// could use if_indextoname to get a name for the interface (remembering that 0 means "do the right thing", i.e. usually any interface, and there are some other special values too; see dns_sd.h)
85-
slog::log<slog::severities::more_info>(gate, SLOG_FLF) << "DNSServiceBrowse for regtype: " << type << " domain: " << domain << " on interface: " << interface_id;
109+
slog::log<slog::severities::more_info>(gate, SLOG_FLF) << "DNSServiceBrowse for regtype: " << type << " domain: " << domain << " on interface: " << put_interface_id(interface_id);
86110

87111
browse_context context{ handler, had_enough, more_coming, gate };
88112
DNSServiceErrorType errorCode = DNSServiceBrowse(&client, 0, interface_id, type.c_str(), !domain.empty() ? domain.c_str() : NULL, browse_reply, &context);
@@ -285,8 +309,7 @@ namespace mdns_details
285309
const auto latest_timeout = now + latest_timeout_;
286310
const auto earliest_timeout = now + earliest_timeout_;
287311

288-
// could use if_indextoname to get a name for the interface (remembering that 0 means "do the right thing", i.e. usually any interface, and there are some other special values too; see dns_sd.h)
289-
slog::log<slog::severities::more_info>(gate, SLOG_FLF) << "DNSServiceResolve for name: " << name << " regtype: " << type << " domain: " << domain << " on interface: " << interface_id;
312+
slog::log<slog::severities::more_info>(gate, SLOG_FLF) << "DNSServiceResolve for name: " << name << " regtype: " << type << " domain: " << domain << " on interface: " << put_interface_id(interface_id);
290313

291314
resolve_context context{ handler, had_enough, more_coming, gate };
292315
DNSServiceErrorType errorCode = DNSServiceResolve(&client, 0, interface_id, name.c_str(), type.c_str(), domain.c_str(), (DNSServiceResolveReply)resolve_reply, &context);
@@ -352,12 +375,12 @@ namespace mdns_details
352375
if (protocol == kDNSServiceProtocol_IPv4 && interface_id >= kIPv6IfIndexBase)
353376
{
354377
// no point trying in this case!
355-
slog::log<slog::severities::too_much_info>(gate, SLOG_FLF) << "DNSServiceGetAddrInfo not tried for hostname: " << host_name << " on interface: " << interface_id;
378+
slog::log<slog::severities::too_much_info>(gate, SLOG_FLF) << "DNSServiceGetAddrInfo not tried for hostname: " << host_name << " on interface: " << put_interface_id(interface_id);
356379
}
357380
else
358381
#endif
359382
{
360-
slog::log<slog::severities::more_info>(gate, SLOG_FLF) << "DNSServiceGetAddrInfo for hostname: " << host_name << " on interface: " << interface_id;
383+
slog::log<slog::severities::more_info>(gate, SLOG_FLF) << "DNSServiceGetAddrInfo for hostname: " << host_name << " on interface: " << put_interface_id(interface_id);
361384

362385
getaddrinfo_context context{ handler, had_enough, more_coming, gate };
363386
DNSServiceErrorType errorCode = DNSServiceGetAddrInfo(&client, 0, interface_id, protocol, host_name.c_str(), getaddrinfo_reply, &context);

Development/nmos-cpp-node/node_implementation.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,7 @@ void node_implementation_init(nmos::node_model& model, nmos::experimental::contr
12601260
{
12611261
const auto receiver_id = impl::make_id(seed_id, nmos::types::receiver, port, index);
12621262

1263-
utility::stringstream_t role;
1263+
utility::ostringstream_t role;
12641264
role << U("monitor-") << ++count;
12651265
const auto& receiver = nmos::find_resource(model.node_resources, receiver_id);
12661266
const auto receiver_monitor = nmos::make_receiver_monitor(++oid, true, nmos::root_block_oid, role.str(), nmos::fields::label(receiver->data), nmos::fields::description(receiver->data), value_of({ { nmos::details::make_nc_touchpoint_nmos({nmos::ncp_nmos_resource_types::receiver, receiver_id}) } }));

Development/nmos/authorization_behaviour.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ namespace nmos
162162
{
163163
return false;
164164
}
165-
auto now = std::chrono::system_clock::now();
166-
auto exp = std::chrono::system_clock::from_time_t(expires_at);
165+
const auto now = std::chrono::system_clock::now();
166+
const auto exp = std::chrono::system_clock::from_time_t(expires_at);
167167
return (now > exp);
168168
};
169169

Development/nmos/certificate_handlers.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace nmos
2222
else
2323
{
2424
utility::ifstream_t ca_file(ca_certificate_file);
25-
utility::stringstream_t cacerts;
25+
utility::ostringstream_t cacerts;
2626
cacerts << ca_file.rdbuf();
2727
return cacerts.str();
2828
}
@@ -70,7 +70,7 @@ namespace nmos
7070
const auto private_key_file = nmos::experimental::fields::private_key_file(server_certificate);
7171
const auto certificate_chain_file = nmos::experimental::fields::certificate_chain_file(server_certificate);
7272

73-
utility::stringstream_t pkey;
73+
utility::ostringstream_t pkey;
7474
if (private_key_file.empty())
7575
{
7676
slog::log<slog::severities::warning>(gate, SLOG_FLF) << "Missing server private key file";
@@ -81,7 +81,7 @@ namespace nmos
8181
pkey << pkey_file.rdbuf();
8282
}
8383

84-
utility::stringstream_t cert_chain;
84+
utility::ostringstream_t cert_chain;
8585
if (certificate_chain_file.empty())
8686
{
8787
slog::log<slog::severities::warning>(gate, SLOG_FLF) << "Missing server certificate chain file";
@@ -114,7 +114,7 @@ namespace nmos
114114
else
115115
{
116116
utility::ifstream_t dh_file(dh_param_file);
117-
utility::stringstream_t dh_param;
117+
utility::ostringstream_t dh_param;
118118
dh_param << dh_file.rdbuf();
119119
return dh_param.str();
120120
}
@@ -160,7 +160,7 @@ namespace nmos
160160
const auto key_algorithm = nmos::experimental::fields::key_algorithm(server_certificate);
161161
const auto private_key_file = nmos::experimental::fields::private_key_file(server_certificate);
162162

163-
utility::stringstream_t pkey;
163+
utility::ostringstream_t pkey;
164164
if (private_key_file.empty())
165165
{
166166
slog::log<slog::severities::warning>(gate, SLOG_FLF) << "Missing private key file";

Development/nmos/client_utils.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,10 @@ namespace nmos
296296
{
297297
slog::log<slog::severities::too_much_info>(gate, SLOG_FLF) << "Sending request";
298298
// see https://developer.mozilla.org/en-US/docs/Web/API/Resource_Timing_API#Resource_loading_timestamps
299-
const auto start_time = std::chrono::system_clock::now();
299+
const auto start_time = std::chrono::steady_clock::now();
300300
return client.request(request, token).then([start_time, &gate](web::http::http_response res)
301301
{
302-
const auto response_start = std::chrono::system_clock::now();
302+
const auto response_start = std::chrono::steady_clock::now();
303303
const auto request_dur = std::chrono::duration_cast<std::chrono::microseconds>(response_start - start_time).count() / 1000.0;
304304

305305
// see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Server-Timing

0 commit comments

Comments
 (0)