Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions handlers/clients_el.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,19 +269,24 @@ func buildELClientsPageData(sortOrder string) (*models.ClientsELPageData, time.D

resPeer := &models.ClientELPageDataNodePeers{
ID: peerID,
State: peer.Name,
Direction: direction,
Alias: peerAlias,
Name: peer.Name,
Enode: enoderaw,
Caps: peer.Caps,
Protocols: buildPeerProtocols(peer.Protocols),
Type: peerType,
}

if pageData.ShowSensitivePeerInfos && strings.HasPrefix(peer.ENR, "enr:") {
resPeer.ENR = peer.ENR
resPeer.ENRKeyValues = getEnrValues(peer.ENR)
// The peer details (enode, name, caps, protocols, ENR) are only rendered
// when ShowSensitivePeerInfos is enabled, so gate them server-side like
// the node's own enode/ENR/IPs to keep them out of the page data.
if pageData.ShowSensitivePeerInfos {
resPeer.State = peer.Name
resPeer.Name = peer.Name
resPeer.Enode = enoderaw
resPeer.Caps = peer.Caps
resPeer.Protocols = buildPeerProtocols(peer.Protocols)
if strings.HasPrefix(peer.ENR, "enr:") {
resPeer.ENR = peer.ENR
resPeer.ENRKeyValues = getEnrValues(peer.ENR)
}
}

resPeers = append(resPeers, resPeer)
Expand Down
30 changes: 28 additions & 2 deletions templates/clients/clients_el.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ <h2 class="accordion-header">
<div style="margin-bottom: 15px; padding: 0 15px;">
<div class="input-group">
<span class="input-group-text"><i class="fas fa-search"></i></span>
<input type="text" class="form-control" id="clientSearchInput" placeholder="Search clients by name...">
<input type="text" class="form-control" id="clientSearchInput" placeholder="Search by name, peer ID, enode, ENR, or IP...">
<button class="btn btn-outline-secondary" type="button" id="clearClientSearch">Clear</button>
</div>
</div>
Expand Down Expand Up @@ -547,16 +547,42 @@ <h5 class="modal-title" id="statusMessageModalTitle">
$('#peerInfo-' + peerId).collapse('show');
});

// Match a node's own identity fields (name, enode, ENR, IPs) and those of
// its connected peers, so searching for an enode, ENR, or IP address also
// finds the clients connected to that peer. Sensitive fields are empty
// when ShowSensitivePeerInfos is disabled, so they simply never match.
function nodeMatchesSearch(node, searchText) {
var fields = [node.name, node.peer_name, node.version, node.enode, node.enr, node.ip_addr, node.listen_addr];
for (var i = 0; i < fields.length; i++) {
if (fields[i] && fields[i].toLowerCase().includes(searchText)) return true;
}
var peers = node.peers || [];
for (var i = 0; i < peers.length; i++) {
var peerFields = [peers[i].id, peers[i].enode, peers[i].enr, peers[i].name];
Comment thread
barnabasbusa marked this conversation as resolved.
for (var j = 0; j < peerFields.length; j++) {
if (peerFields[j] && peerFields[j].toLowerCase().includes(searchText)) return true;
}
}
return false;
}

// Client search functionality
$('#clientSearchInput').on('input', function() {
var searchText = $(this).val().trim().toLowerCase();

$('#clients tbody tr').each(function() {
if (!$(this).hasClass('peerInfo')) {
var clientName = $(this).find('.client-row a').text().toLowerCase();
var peerId = ($(this).find('.client-row').data('peerid') || '') + '';
var peerInfoRow = $(this).next('.peerInfo');
var node = nodes[peerId] || {};

var matches = searchText === '' ||
clientName.includes(searchText) ||
peerId.toLowerCase().includes(searchText) ||
nodeMatchesSearch(node, searchText);

if (searchText === '' || clientName.includes(searchText)) {
if (matches) {
$(this).show();
peerInfoRow.css('display', '');
} else {
Expand Down