Skip to content

Commit 5a96f10

Browse files
committed
add peer ID editor; implement support in the peer lookup and FNE to validate whether or not a peer can perform a encryption key request;
1 parent 6927ea2 commit 5a96f10

17 files changed

Lines changed: 1997 additions & 17 deletions

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ if (NOT TARGET strip)
298298
COMMAND arm-linux-gnueabihf-strip -s dvmmon
299299
COMMAND arm-linux-gnueabihf-strip -s sysview
300300
COMMAND arm-linux-gnueabihf-strip -s tged
301+
COMMAND arm-linux-gnueabihf-strip -s peered
301302
COMMAND arm-linux-gnueabihf-strip -s dvmbridge)
302303
else()
303304
add_custom_target(strip
@@ -315,6 +316,7 @@ if (NOT TARGET strip)
315316
COMMAND aarch64-linux-gnu-strip -s dvmmon
316317
COMMAND aarch64-linux-gnu-strip -s sysview
317318
COMMAND aarch64-linux-gnu-strip -s tged
319+
COMMAND aarch64-linux-gnu-strip -s peered
318320
COMMAND aarch64-linux-gnu-strip -s dvmbridge)
319321
else()
320322
add_custom_target(strip
@@ -346,6 +348,7 @@ if (NOT TARGET strip)
346348
COMMAND strip -s dvmmon
347349
COMMAND strip -s sysview
348350
COMMAND strip -s tged
351+
COMMAND strip -s peered
349352
COMMAND strip -s dvmbridge)
350353
else()
351354
add_custom_target(strip
@@ -379,6 +382,7 @@ if (NOT TARGET tarball)
379382
COMMAND cp -v dvmmon ${CMAKE_INSTALL_PREFIX_TARBALL}/dvm/bin
380383
COMMAND cp -v sysview ${CMAKE_INSTALL_PREFIX_TARBALL}/dvm/bin
381384
COMMAND cp -v tged ${CMAKE_INSTALL_PREFIX_TARBALL}/dvm/bin
385+
COMMAND cp -v peered ${CMAKE_INSTALL_PREFIX_TARBALL}/dvm/bin
382386
COMMAND cp -v dvmfne ${CMAKE_INSTALL_PREFIX_TARBALL}/dvm/bin
383387
COMMAND cp -v dvmbridge ${CMAKE_INSTALL_PREFIX_TARBALL}/dvm/bin
384388
COMMAND cp ${CMAKE_SOURCE_DIR}/tools/*.sh ${CMAKE_INSTALL_PREFIX_TARBALL}/dvm
@@ -457,6 +461,7 @@ if (NOT TARGET tarball_notools)
457461
COMMAND cp -v dvmmon ${CMAKE_INSTALL_PREFIX_TARBALL}/dvm/bin
458462
COMMAND cp -v sysview ${CMAKE_INSTALL_PREFIX_TARBALL}/dvm/bin
459463
COMMAND cp -v tged ${CMAKE_INSTALL_PREFIX_TARBALL}/dvm/bin
464+
COMMAND cp -v peered ${CMAKE_INSTALL_PREFIX_TARBALL}/dvm/bin
460465
COMMAND cp -v dvmfne ${CMAKE_INSTALL_PREFIX_TARBALL}/dvm/bin
461466
COMMAND cp -v dvmbridge ${CMAKE_INSTALL_PREFIX_TARBALL}/dvm/bin
462467
COMMAND cp -v ${CMAKE_SOURCE_DIR}/configs/*.yml ${CMAKE_INSTALL_PREFIX_TARBALL}/dvm
@@ -532,6 +537,7 @@ add_custom_target(old_install
532537
COMMAND install -m 755 dvmmon ${CMAKE_LEGACY_INSTALL_PREFIX}/bin
533538
COMMAND install -m 755 sysview ${CMAKE_LEGACY_INSTALL_PREFIX}/bin
534539
COMMAND install -m 755 tged ${CMAKE_LEGACY_INSTALL_PREFIX}/bin
540+
COMMAND install -m 755 peered ${CMAKE_LEGACY_INSTALL_PREFIX}/bin
535541
COMMAND install -m 755 dvmfne ${CMAKE_LEGACY_INSTALL_PREFIX}/bin
536542
COMMAND install -m 755 dvmbridge ${CMAKE_LEGACY_INSTALL_PREFIX}/bin
537543
COMMAND install -m 644 ${CMAKE_SOURCE_DIR}/configs/config.example.yml ${CMAKE_LEGACY_INSTALL_PREFIX}/config.example.yml

configs/peer_list.example.dat

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#
22
# This file sets the valid peer IDs allowed on a FNE.
33
#
4-
# Entry Format: "Peer ID,Peer Password,Peer Link (1 = Enabled / 0 = Disabled),Peer Alias (optional),<newline>"
5-
#1234,,0,
6-
#5678,MYSECUREPASSWORD,0,
7-
#9876,MYSECUREPASSWORD,1,
8-
#5432,MYSECUREPASSWORD,,Peer Alias 1,
9-
#1012,MYSECUREPASSWORD,1,Peer Alias 2,
4+
# Entry Format: "Peer ID,Peer Password,Peer Link (1 = Enabled / 0 = Disabled),Peer Alias (optional),Can Request Keys (1 = Enabled / 0 = Disabled),<newline>"
5+
#1234,,0,,1,
6+
#5678,MYSECUREPASSWORD,0,,0,
7+
#9876,MYSECUREPASSWORD,1,,0,
8+
#5432,MYSECUREPASSWORD,,Peer Alias 1,0,
9+
#1012,MYSECUREPASSWORD,1,Peer Alias 2,1,

src/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,16 @@ if (ENABLE_TUI_SUPPORT AND (NOT DISABLE_TUI_APPS))
113113
target_include_directories(tged PRIVATE ${OPENSSL_INCLUDE_DIR} websocketpp src src/host src/tged)
114114
endif (ENABLE_TUI_SUPPORT AND (NOT DISABLE_TUI_APPS))
115115

116+
#
117+
## peered
118+
#
119+
if (ENABLE_TUI_SUPPORT AND (NOT DISABLE_TUI_APPS))
120+
include(src/peered/CMakeLists.txt)
121+
add_executable(peered ${common_INCLUDE} ${peered_SRC})
122+
target_link_libraries(peered PRIVATE common ${OPENSSL_LIBRARIES} asio::asio finalcut Threads::Threads)
123+
target_include_directories(peered PRIVATE ${OPENSSL_INCLUDE_DIR} websocketpp src src/host src/peered)
124+
endif (ENABLE_TUI_SUPPORT AND (NOT DISABLE_TUI_APPS))
125+
116126
#
117127
## dvmcmd
118128
#

src/common/lookups/PeerListLookup.cpp

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
66
*
77
* Copyright (C) 2016 Jonathan Naylor, G4KLX
8-
* Copyright (C) 2017-2022,2024 Bryan Biedenkapp, N2PLL
8+
* Copyright (C) 2017-2022,2024,2025 Bryan Biedenkapp, N2PLL
99
* Copyright (c) 2024 Patrick McDonnell, W3AXL
1010
* Copyright (c) 2024 Caleb, KO4UYJ
1111
*
@@ -46,16 +46,16 @@ void PeerListLookup::clear()
4646

4747
/* Adds a new entry to the list. */
4848

49-
void PeerListLookup::addEntry(uint32_t id, const std::string& alias, const std::string& password, bool peerLink)
49+
void PeerListLookup::addEntry(uint32_t id, const std::string& alias, const std::string& password, bool peerLink, bool canRequestKeys)
5050
{
51-
PeerId entry = PeerId(id, alias, password, peerLink, false);
51+
PeerId entry = PeerId(id, alias, password, peerLink, canRequestKeys, false);
5252

5353
std::lock_guard<std::mutex> lock(m_mutex);
5454
try {
5555
PeerId _entry = m_table.at(id);
5656
// if either the alias or the enabled flag doesn't match, update the entry
5757
if (_entry.peerId() == id) {
58-
_entry = PeerId(id, alias, password, peerLink, false);
58+
_entry = PeerId(id, alias, password, peerLink, canRequestKeys, false);
5959
m_table[id] = _entry;
6060
}
6161
} catch (...) {
@@ -87,7 +87,7 @@ PeerId PeerListLookup::find(uint32_t id)
8787
try {
8888
entry = m_table.at(id);
8989
} catch (...) {
90-
entry = PeerId(0U, "", "", false, true);
90+
entry = PeerId(0U, "", "", false, false, true);
9191
}
9292

9393
return entry;
@@ -226,19 +226,25 @@ bool PeerListLookup::load()
226226
if (parsed.size() >= 3)
227227
peerLink = ::atoi(parsed[2].c_str()) == 1;
228228

229+
// Parse can request keys flag
230+
bool canRequestKeys = false;
231+
if (parsed.size() >= 5)
232+
canRequestKeys = ::atoi(parsed[4].c_str()) == 1;
233+
229234
// Parse optional password
230235
std::string password = "";
231236
if (parsed.size() >= 2)
232237
password = parsed[1].c_str();
233238

234239
// Load into table
235-
m_table[id] = PeerId(id, alias, password, peerLink, false);
240+
m_table[id] = PeerId(id, alias, password, peerLink, canRequestKeys, false);
236241

237242
// Log depending on what was loaded
238243
LogMessage(LOG_HOST, "Loaded peer ID %u%s into peer ID lookup table, %s%s", id,
239244
(!alias.empty() ? (" (" + alias + ")").c_str() : ""),
240245
(!password.empty() ? "using unique peer password" : "using master password"),
241-
(peerLink) ? ", Peer-Link Enabled" : "");
246+
(peerLink) ? ", Peer-Link Enabled" : "",
247+
(canRequestKeys) ? ", Can Request Keys" : "");
242248
}
243249
}
244250

@@ -299,6 +305,15 @@ bool PeerListLookup::save()
299305
if (alias.length() > 0) {
300306
line += alias;
301307
line += ",";
308+
} else {
309+
line += ",";
310+
}
311+
// Add canRequestKeys flag
312+
bool canRequestKeys = entry.second.canRequestKeys();
313+
if (canRequestKeys) {
314+
line += "1,";
315+
} else {
316+
line += "0,";
302317
}
303318
// Add the newline
304319
line += "\n";

src/common/lookups/PeerListLookup.h

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
66
*
77
* Copyright (C) 2016 Jonathan Naylor, G4KLX
8-
* Copyright (C) 2017-2022,2024 Bryan Biedenkapp, N2PLL
8+
* Copyright (C) 2017-2022,2024,2025 Bryan Biedenkapp, N2PLL
99
* Copyright (c) 2024 Patrick McDonnell, W3AXL
1010
* Copyright (c) 2024 Caleb, KO4UYJ
1111
*
@@ -50,6 +50,7 @@ namespace lookups
5050
m_peerAlias(),
5151
m_peerPassword(),
5252
m_peerLink(false),
53+
m_canRequestKeys(false),
5354
m_peerDefault(false)
5455
{
5556
/* stub */
@@ -60,13 +61,16 @@ namespace lookups
6061
* @param peerAlias Peer alias
6162
* @param peerPassword Per Peer Password.
6263
* @param sendConfiguration Flag indicating this peer participates in peer link and should be sent configuration.
64+
* @param peerLink lag indicating if the peer participates in peer link and should be sent configuration.
65+
* @param canRequestKeys Flag indicating if the peer can request encryption keys.
6366
* @param peerDefault Flag indicating this is a "default" (i.e. undefined) peer.
6467
*/
65-
PeerId(uint32_t peerId, const std::string& peerAlias, const std::string& peerPassword, bool peerLink, bool peerDefault) :
68+
PeerId(uint32_t peerId, const std::string& peerAlias, const std::string& peerPassword, bool peerLink, bool canRequestKeys, bool peerDefault) :
6669
m_peerId(peerId),
6770
m_peerAlias(peerAlias),
6871
m_peerPassword(peerPassword),
6972
m_peerLink(peerLink),
73+
m_canRequestKeys(canRequestKeys),
7074
m_peerDefault(peerDefault)
7175
{
7276
/* stub */
@@ -83,6 +87,7 @@ namespace lookups
8387
m_peerAlias = data.m_peerAlias;
8488
m_peerPassword = data.m_peerPassword;
8589
m_peerLink = data.m_peerLink;
90+
m_canRequestKeys = data.m_canRequestKeys;
8691
m_peerDefault = data.m_peerDefault;
8792
}
8893

@@ -95,14 +100,17 @@ namespace lookups
95100
* @param peerAlias Peer Alias
96101
* @param peerPassword Per Peer Password.
97102
* @param sendConfiguration Flag indicating this peer participates in peer link and should be sent configuration.
103+
* @param peerLink lag indicating if the peer participates in peer link and should be sent configuration.
104+
* @param canRequestKeys Flag indicating if the peer can request encryption keys.
98105
* @param peerDefault Flag indicating this is a "default" (i.e. undefined) peer.
99106
*/
100-
void set(uint32_t peerId, const std::string& peerAlias, const std::string& peerPassword, bool peerLink, bool peerDefault)
107+
void set(uint32_t peerId, const std::string& peerAlias, const std::string& peerPassword, bool peerLink, bool canRequestKeys, bool peerDefault)
101108
{
102109
m_peerId = peerId;
103110
m_peerAlias = peerAlias;
104111
m_peerPassword = peerPassword;
105112
m_peerLink = peerLink;
113+
m_canRequestKeys = canRequestKeys;
106114
m_peerDefault = peerDefault;
107115
}
108116

@@ -123,6 +131,10 @@ namespace lookups
123131
* @brief Flag indicating if the peer participates in peer link and should be sent configuration.
124132
*/
125133
__PROPERTY_PLAIN(bool, peerLink);
134+
/**
135+
* @brief Flag indicating if the peer can request encryption keys.
136+
*/
137+
__PROPERTY_PLAIN(bool, canRequestKeys);
126138
/**
127139
* @brief Flag indicating if the peer is default.
128140
*/
@@ -166,8 +178,9 @@ namespace lookups
166178
* @param peerId Unique peer ID to add.
167179
* @param password Per Peer Password.
168180
* @param peerLink Flag indicating this peer will participate in peer link and should be sent configuration.
181+
* @param canRequestKeys Flag indicating if the peer can request encryption keys.
169182
*/
170-
void addEntry(uint32_t id, const std::string& alias = "", const std::string& password = "", bool peerLink = false);
183+
void addEntry(uint32_t id, const std::string& alias = "", const std::string& password = "", bool peerLink = false, bool canRequestKeys = false);
171184
/**
172185
* @brief Removes an existing entry from the list.
173186
* @param peerId Unique peer ID to remove.

src/fne/network/FNENetwork.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,19 @@ void* FNENetwork::threadedNetworkRx(void* arg)
11021102

11031103
// validate peer (simple validation really)
11041104
if (connection->connected() && connection->address() == ip) {
1105+
// is this peer allowed to request keys?
1106+
if (network->m_peerListLookup->getACL()) {
1107+
if (network->m_peerListLookup->getMode() == lookups::PeerListLookup::WHITELIST) {
1108+
lookups::PeerId peerEntry = network->m_peerListLookup->find(peerId);
1109+
if (peerEntry.peerDefault()) {
1110+
break;
1111+
} else {
1112+
if (!peerEntry.canRequestKeys())
1113+
break;
1114+
}
1115+
}
1116+
}
1117+
11051118
std::unique_ptr<KMMFrame> frame = KMMFactory::create(req->buffer + 11U);
11061119
if (frame == nullptr) {
11071120
LogWarning(LOG_NET, "PEER %u (%s), undecodable KMM frame from peer", peerId, connection->identity().c_str());

src/peered/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
#/*
3+
# * Digital Voice Modem - Peer ID Editor
4+
# * GPLv2 Open Source. Use is subject to license terms.
5+
# * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6+
# *
7+
# * Copyright (C) 2024 Bryan Biedenkapp, N2PLL
8+
# *
9+
# */
10+
file(GLOB peered_SRC
11+
"src/peered/*.h"
12+
"src/peered/*.cpp"
13+
)

0 commit comments

Comments
 (0)