<server uuid="1a43f632-c3c0-41aa-a72e-e029cd53624b"> <enabled>0</enabled> <name>dummy_instance</name> <instance>0</instance> <pubkey>TWhRzosD0WTmMzmI3ObQnKVvcQ8JhwDUgtr8VvbMakk=</pubkey> <privkey>uG6aKC5LEIIbTgW0yD66Opotj5b76T2agJP2oasdd22=</privkey> <port>606</port> <mtu/> <dns>103.86.96.100,103.86.99.100</dns> <tunneladdress>10.4.0.2/16</tunneladdress> <disableroutes>1</disableroutes> <gateway>10.4.0.1</gateway> <carp_depend_on/> </server>
super.updateTable('wgTunnelTable', [[header, row]], tunnel.publicKey);
let modifiedPublicKey = `${tunnel.publicKey}-${index}`; // Update the HTML table with the sorted rows super.updateTable('wgTunnelTable', [[header, row]], modifiedPublicKey);[/font]
tunnels.forEach((tunnel, index) => { // 'index' gives you the current position in the loop let header = ` <div style="display: flex; justify-content: space-between; align-items: center;"> <div style="display: flex; align-items: center;"> <i class="fa ${tunnel.statusIcon} wireguard-interface" style="cursor: pointer;" data-toggle="tooltip" title="${tunnel.connected ? this.translations.online : this.translations.offline}"> </i> <span><b>${tunnel.ifname}</b></span> </div> </div>`; let row = ` <div> <span><a href="/ui/wireguard/general#peers">${tunnel.name}</a> | ${tunnel.allowed_ips}</span> </div> <div> ${tunnel.latest_handshake_fmt ? `<span>${tunnel.latest_handshake_fmt}</span> <div style="padding-bottom: 10px;"> <i class="fa fa-arrow-down" style="font-size: 13px;"></i> ${tunnel.rx} | <i class="fa fa-arrow-up" style="font-size: 13px;"></i> ${tunnel.tx} </div>` : `<span>${this.translations.disconnected}</span>`} </div>`; // Add '-0', '-1', etc. to the public key using the index let modifiedPublicKey = `${tunnel.publicKey}-${index}`; // Update the HTML table with the sorted rows super.updateTable('wgTunnelTable', [[header, row]], modifiedPublicKey);});