peerpigeon 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1187 -0
  3. package/examples/browser/app-dht-disabled.js +42 -0
  4. package/examples/browser/app.js +51 -0
  5. package/examples/browser/assets/images/favicon.png +0 -0
  6. package/examples/browser/assets/images/pigeon.png +0 -0
  7. package/examples/browser/index-dht-disabled.html +123 -0
  8. package/examples/browser/index.html +340 -0
  9. package/examples/browser/styles.css +1288 -0
  10. package/examples/browser/ui-clean.js +0 -0
  11. package/examples/browser/ui.js +1930 -0
  12. package/index.js +8 -0
  13. package/package.json +70 -0
  14. package/server/index.js +515 -0
  15. package/src/CleanupManager.js +181 -0
  16. package/src/ConnectionManager.js +841 -0
  17. package/src/EventEmitter.js +27 -0
  18. package/src/EvictionManager.js +257 -0
  19. package/src/GossipManager.js +416 -0
  20. package/src/MediaManager.js +225 -0
  21. package/src/MeshOptimizer.js +181 -0
  22. package/src/PeerConnection.js +831 -0
  23. package/src/PeerDiscovery.js +297 -0
  24. package/src/PeerPigeonMesh.js +703 -0
  25. package/src/SignalingClient.js +536 -0
  26. package/src/SignalingHandler.js +325 -0
  27. package/src/StorageManager.js +88 -0
  28. package/src/TimerUtils.js +46 -0
  29. package/src/WebDHT.js +1099 -0
  30. package/websocket-server/README.md +257 -0
  31. package/websocket-server/memory-leak-test.js +193 -0
  32. package/websocket-server/node_modules/.package-lock.json +29 -0
  33. package/websocket-server/node_modules/ws/LICENSE +20 -0
  34. package/websocket-server/node_modules/ws/README.md +548 -0
  35. package/websocket-server/node_modules/ws/browser.js +8 -0
  36. package/websocket-server/node_modules/ws/index.js +13 -0
  37. package/websocket-server/node_modules/ws/lib/buffer-util.js +131 -0
  38. package/websocket-server/node_modules/ws/lib/constants.js +18 -0
  39. package/websocket-server/node_modules/ws/lib/event-target.js +292 -0
  40. package/websocket-server/node_modules/ws/lib/extension.js +203 -0
  41. package/websocket-server/node_modules/ws/lib/limiter.js +55 -0
  42. package/websocket-server/node_modules/ws/lib/permessage-deflate.js +528 -0
  43. package/websocket-server/node_modules/ws/lib/receiver.js +706 -0
  44. package/websocket-server/node_modules/ws/lib/sender.js +602 -0
  45. package/websocket-server/node_modules/ws/lib/stream.js +161 -0
  46. package/websocket-server/node_modules/ws/lib/subprotocol.js +62 -0
  47. package/websocket-server/node_modules/ws/lib/validation.js +152 -0
  48. package/websocket-server/node_modules/ws/lib/websocket-server.js +550 -0
  49. package/websocket-server/node_modules/ws/lib/websocket.js +1388 -0
  50. package/websocket-server/node_modules/ws/package.json +69 -0
  51. package/websocket-server/node_modules/ws/wrapper.mjs +8 -0
  52. package/websocket-server/package-lock.json +39 -0
  53. package/websocket-server/server.js +298 -0
  54. package/websocket-server/test.js +133 -0
@@ -0,0 +1,42 @@
1
+ import { PeerPigeonMesh } from '../../src/PeerPigeonMesh.js';
2
+ import { PeerPigeonUI } from './ui.js';
3
+
4
+ class PeerPigeonApp {
5
+ constructor() {
6
+ // Test: Initialize mesh with WebDHT disabled to demonstrate the UI setting
7
+ this.mesh = new PeerPigeonMesh({ enableWebDHT: false });
8
+
9
+ // To enable WebDHT (default), use:
10
+ // this.mesh = new PeerPigeonMesh();
11
+ // this.mesh = new PeerPigeonMesh({ enableWebDHT: true });
12
+
13
+ this.ui = new PeerPigeonUI(this.mesh);
14
+ this.init();
15
+ }
16
+
17
+ async init() {
18
+ try {
19
+ await this.mesh.init();
20
+ this.ui.updateUI();
21
+ this.setupUnloadHandler();
22
+ } catch (error) {
23
+ console.error('Failed to initialize app:', error);
24
+ }
25
+ }
26
+
27
+ setupUnloadHandler() {
28
+ const handleUnload = () => {
29
+ if (this.mesh.connected) {
30
+ this.mesh.sendGoodbyeMessage();
31
+ }
32
+ };
33
+
34
+ window.addEventListener('beforeunload', handleUnload);
35
+ window.addEventListener('unload', handleUnload);
36
+ }
37
+ }
38
+
39
+ // Initialize the app when the page loads
40
+ document.addEventListener('DOMContentLoaded', () => {
41
+ new PeerPigeonApp();
42
+ });
@@ -0,0 +1,51 @@
1
+ import { PeerPigeonMesh } from '../../src/PeerPigeonMesh.js';
2
+ import { PeerPigeonUI } from './ui.js';
3
+
4
+ class PeerPigeonApp {
5
+ constructor() {
6
+ // Initialize mesh with default options (WebDHT enabled)
7
+ this.mesh = new PeerPigeonMesh();
8
+
9
+ // To disable WebDHT, use:
10
+ // this.mesh = new PeerPigeonMesh({ enableWebDHT: false });
11
+
12
+ this.ui = new PeerPigeonUI(this.mesh);
13
+ this.init();
14
+ }
15
+
16
+ async init() {
17
+ try {
18
+ await this.mesh.init();
19
+ this.ui.updateUI();
20
+ this.setupUnloadHandler();
21
+ } catch (error) {
22
+ console.error('Failed to initialize app:', error);
23
+ }
24
+ }
25
+
26
+ setupUnloadHandler() {
27
+ const handleUnload = () => {
28
+ if (this.mesh.connected) {
29
+ this.mesh.sendGoodbyeMessage();
30
+ }
31
+ };
32
+
33
+ window.addEventListener('beforeunload', handleUnload);
34
+ window.addEventListener('unload', handleUnload);
35
+ }
36
+ }
37
+
38
+ // Initialize the application
39
+ document.addEventListener('DOMContentLoaded', () => {
40
+ const peerPigeonApp = new PeerPigeonApp();
41
+
42
+ // Expose for debugging and global access
43
+ window.peerPigeonApp = peerPigeonApp;
44
+ window.peerPigeonMesh = peerPigeonApp.mesh;
45
+ window.peerPigeonUI = peerPigeonApp.ui;
46
+ window.peerPigeonSignaling = peerPigeonApp.mesh.signalingClient;
47
+ window.getPeerPigeonState = () => peerPigeonApp.mesh.getStatus();
48
+
49
+ // Expose PeerPigeonMesh class for static validation in UI
50
+ window.PeerPigeonMesh = PeerPigeonMesh;
51
+ });
@@ -0,0 +1,123 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>PeerPigeon - DHT Disabled Demo</title>
7
+ <link rel="icon" type="image/png" href="assets/images/favicon.png">
8
+ <link rel="stylesheet" href="styles.css">
9
+ <style>
10
+ .demo-notice {
11
+ background: #fff3cd;
12
+ border: 1px solid #ffeaa7;
13
+ border-radius: 6px;
14
+ padding: 12px;
15
+ margin: 20px auto;
16
+ max-width: 600px;
17
+ text-align: center;
18
+ color: #856404;
19
+ font-weight: 500;
20
+ }
21
+ </style>
22
+ </head>
23
+ <body>
24
+ <div class="container">
25
+ <header>
26
+ <h1>
27
+ <img src="assets/images/pigeon.png" alt="PeerPigeon Logo">
28
+ PeerPigeon Demo - DHT Disabled
29
+ </h1>
30
+ <p>WebRTC-based peer-to-peer mesh networking with intelligent routing</p>
31
+ <div class="demo-notice">
32
+ 🔧 <strong>Demo Mode:</strong> This demo shows PeerPigeon with WebDHT disabled.
33
+ Check the Settings section to see the DHT status indicator.
34
+ </div>
35
+ <div class="usage-hint">
36
+ <strong>Quick Start:</strong>
37
+ 1. Open multiple browser tabs/windows with this page<br>
38
+ 2. Enter a signaling server URL (or use <code>?api=your-api-gateway-url</code> in URL)<br>
39
+ 3. Click Connect - all tabs will automatically discover and connect to each other<br>
40
+ 4. Notice that DHT operations will show error messages since DHT is disabled
41
+ </div>
42
+ </header>
43
+
44
+ <main>
45
+ <!-- Include the same content as index.html but referencing the modified app.js -->
46
+ <!-- Copy the entire main content from index.html -->
47
+ <div class="peer-info">
48
+ <div class="section-header">
49
+ <h2>
50
+ <button id="peer-info-toggle" class="toggle-btn" aria-expanded="true">
51
+ ▼ Peer Info
52
+ </button>
53
+ </h2>
54
+ </div>
55
+ <div id="peer-info-content" class="collapsible-content">
56
+ <div class="info-group">
57
+ <label>Peer ID:</label>
58
+ <span id="peer-id">Not initialized</span>
59
+ </div>
60
+ <div class="info-group">
61
+ <label>Status:</label>
62
+ <span id="status" class="status disconnected">Disconnected</span>
63
+ </div>
64
+ <div class="info-group">
65
+ <label>Connected Peers:</label>
66
+ <span id="peer-count">0</span>
67
+ </div>
68
+ <div class="input-group">
69
+ <label for="signaling-url-main">Signaling Server URL:</label>
70
+ <div class="input-group horizontal">
71
+ <input type="url" id="signaling-url-main"
72
+ placeholder="https://your-api-gateway.execute-api.region.amazonaws.com/dev">
73
+ <div class="button-group">
74
+ <button id="connect-btn" class="btn primary">Connect</button>
75
+ <button id="disconnect-btn" class="btn secondary" disabled>Disconnect</button>
76
+ </div>
77
+ </div>
78
+ <small class="input-help">
79
+ Auto-populated from ?api, ?url, or ?signaling query parameters
80
+ </small>
81
+ </div>
82
+ </div>
83
+ </div>
84
+
85
+ <!-- Rest of the UI components would go here... -->
86
+ <!-- For brevity, showing just the key Settings section -->
87
+
88
+ <div class="settings" aria-expanded="false">
89
+ <div class="section-header">
90
+ <h2>
91
+ <button id="settings-toggle" class="toggle-btn" aria-expanded="false">
92
+ ▶ Settings
93
+ </button>
94
+ </h2>
95
+ </div>
96
+ <div id="settings-content" class="collapsible-content" style="display: none;">
97
+ <div class="input-group">
98
+ <label for="signaling-url">Signaling Server URL:</label>
99
+ <input type="url" id="signaling-url"
100
+ placeholder="https://your-api-gateway.execute-api.region.amazonaws.com/dev">
101
+ <small class="input-help">
102
+ Auto-populated from ?api, ?url, or ?signaling query parameters. Enter base API Gateway URL (without /signaling path).
103
+ </small>
104
+ </div>
105
+
106
+ <div class="auto-discovery-control">
107
+ <label class="checkbox-label">
108
+ <input type="checkbox" id="webdht-toggle" checked disabled>
109
+ <span class="checkmark"></span>
110
+ Enable WebDHT (Distributed Hash Table)
111
+ </label>
112
+ <small class="input-help">
113
+ WebDHT status (configured at startup, restart required to change)
114
+ </small>
115
+ </div>
116
+ </div>
117
+ </div>
118
+ </main>
119
+ </div>
120
+
121
+ <script type="module" src="app-dht-disabled.js"></script>
122
+ </body>
123
+ </html>
@@ -0,0 +1,340 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>PeerPigeon - WebRTC P2P Mesh</title>
7
+ <link rel="stylesheet" href="styles.css">
8
+ <link rel="icon" type="image/png" sizes="32x32" href="assets/images/favicon.png">
9
+ <link rel="icon" type="image/png" sizes="16x16" href="assets/images/favicon.png">
10
+ <link rel="apple-touch-icon" href="assets/images/favicon.png">
11
+ <link rel="shortcut icon" href="assets/images/favicon.png">
12
+ </head>
13
+ <body>
14
+ <div class="container">
15
+ <header>
16
+ <h1><img src="assets/images/favicon.png" alt="PeerPigeon Logo" style="height: 2.5em; width: auto; vertical-align: middle; margin-right: 0.5em;"> PeerPigeon</h1>
17
+ <p>WebRTC P2P mesh networking with XOR-based routing</p>
18
+ <div class="usage-hint">
19
+ <strong>Tip:</strong> You can pass the API Gateway URL via query parameter:<br>
20
+ <code>?api=https://your-api-gateway.execute-api.region.amazonaws.com/dev</code>
21
+ </div>
22
+ </header>
23
+
24
+ <main>
25
+ <div class="peer-info">
26
+ <h2>Peer Information</h2>
27
+ <div class="info-group">
28
+ <label>Your Peer ID:</label>
29
+ <code id="peer-id">Generating...</code>
30
+ </div>
31
+ <div class="info-group">
32
+ <label>Status:</label>
33
+ <span id="status" class="status disconnected">Disconnected</span>
34
+ </div>
35
+ </div>
36
+
37
+ <div class="connection-controls">
38
+ <h2>Connection</h2>
39
+ <div class="button-group">
40
+ <button id="connect-btn" class="btn primary">Connect</button>
41
+ <button id="disconnect-btn" class="btn secondary" disabled>Disconnect</button>
42
+ <button id="cleanup-btn" class="btn tertiary" disabled>Clean Signaling Data</button>
43
+ <button id="health-check-btn" class="btn quaternary" disabled>Health Check</button>
44
+ <button id="refresh-btn" class="btn quaternary">🔄 Refresh Page</button>
45
+ </div>
46
+
47
+ <div class="system-messages-container">
48
+ <div id="system-messages" class="system-messages"></div>
49
+ </div>
50
+ </div>
51
+
52
+ <div class="media" aria-expanded="false">
53
+ <div class="section-header">
54
+ <h2>
55
+ <button id="media-toggle" class="toggle-btn" aria-expanded="false">
56
+ ▶ Video/Audio
57
+ </button>
58
+ </h2>
59
+ </div>
60
+ <div id="media-content" class="collapsible-content" style="display: none;">
61
+ <div class="media-controls">
62
+ <div class="input-group">
63
+ <label>Media Types:</label>
64
+ <div class="checkbox-group">
65
+ <label class="checkbox-label">
66
+ <input type="checkbox" id="enable-video">
67
+ <span class="checkmark"></span>
68
+ Enable Video
69
+ </label>
70
+ <label class="checkbox-label">
71
+ <input type="checkbox" id="enable-audio">
72
+ <span class="checkmark"></span>
73
+ Enable Audio
74
+ </label>
75
+ </div>
76
+ </div>
77
+
78
+ <div class="input-group">
79
+ <label for="camera-select">Camera:</label>
80
+ <select id="camera-select" disabled>
81
+ <option value="">Select camera...</option>
82
+ </select>
83
+ </div>
84
+
85
+ <div class="input-group">
86
+ <label for="microphone-select">Microphone:</label>
87
+ <select id="microphone-select" disabled>
88
+ <option value="">Select microphone...</option>
89
+ </select>
90
+ </div>
91
+
92
+ <div class="button-group">
93
+ <button id="start-media-btn" class="btn primary" disabled>Start Media</button>
94
+ <button id="stop-media-btn" class="btn secondary" disabled>Stop Media</button>
95
+ <button id="toggle-video-btn" class="btn tertiary" disabled>Toggle Video</button>
96
+ <button id="toggle-audio-btn" class="btn tertiary" disabled>Toggle Audio</button>
97
+ <button id="test-audio-btn" class="btn warning">🔊 Test Audio</button>
98
+ </div>
99
+
100
+ <div class="local-video">
101
+ <h4>Your Video</h4>
102
+ <div id="local-video-container" class="video-container">
103
+ <p class="video-placeholder">No video stream</p>
104
+ </div>
105
+ </div>
106
+
107
+ <div class="remote-videos">
108
+ <h4>Peer Videos</h4>
109
+ <div id="remote-videos-container" class="videos-grid">
110
+ <p class="video-placeholder">No remote video streams</p>
111
+ </div>
112
+ </div>
113
+ </div>
114
+ </div>
115
+ </div>
116
+
117
+ <div class="discovered-peers" aria-expanded="false">
118
+ <div class="section-header">
119
+ <h2>
120
+ <button id="discovered-peers-toggle" class="toggle-btn" aria-expanded="false">
121
+ ▶ Discovered Peers
122
+ </button>
123
+ <span id="discovered-peers-count" class="count-badge">0</span>
124
+ </h2>
125
+ </div>
126
+ <div id="discovered-peers-content" class="collapsible-content" style="display: none;">
127
+ <div id="discovered-peers-list" class="discovered-peers-list">
128
+ <p class="empty-state">No peers discovered</p>
129
+ </div>
130
+ </div>
131
+ </div>
132
+
133
+ <div class="connected-peers" aria-expanded="false">
134
+ <div class="section-header">
135
+ <h2>
136
+ <button id="connected-peers-toggle" class="toggle-btn" aria-expanded="false">
137
+ ▶ Connected Peers
138
+ </button>
139
+ <span id="connected-peers-count" class="count-badge">0</span>
140
+ </h2>
141
+ </div>
142
+ <div id="connected-peers-content" class="collapsible-content" style="display: none;">
143
+ <div id="peers-list" class="peers-list">
144
+ <p class="empty-state">No peers connected</p>
145
+ </div>
146
+ </div>
147
+ </div>
148
+
149
+ <div class="manual-connection" aria-expanded="false">
150
+ <div class="section-header">
151
+ <h2>
152
+ <button id="manual-connection-toggle" class="toggle-btn" aria-expanded="false">
153
+ ▶ Manual Connection
154
+ </button>
155
+ </h2>
156
+ </div>
157
+ <div id="manual-connection-content" class="collapsible-content" style="display: none;">
158
+ <div class="input-group">
159
+ <label for="target-peer">Target Peer ID (40-character SHA-1 hash):</label>
160
+ <div class="input-group horizontal">
161
+ <input type="text" id="target-peer"
162
+ placeholder="Enter 40-character SHA-1 hash"
163
+ maxlength="40"
164
+ pattern="[a-fA-F0-9]{40}">
165
+ <button id="connect-peer-btn" class="btn secondary">Connect to Peer</button>
166
+ </div>
167
+ <small class="input-help">
168
+ Manually connect to a specific peer ID
169
+ </small>
170
+ </div>
171
+ </div>
172
+ </div>
173
+
174
+ <div class="settings" aria-expanded="false">
175
+ <div class="section-header">
176
+ <h2>
177
+ <button id="settings-toggle" class="toggle-btn" aria-expanded="false">
178
+ ▶ Settings
179
+ </button>
180
+ </h2>
181
+ </div>
182
+ <div id="settings-content" class="collapsible-content" style="display: none;">
183
+ <div class="input-group">
184
+ <label for="signaling-url">Signaling Server URL:</label>
185
+ <input type="url" id="signaling-url"
186
+ placeholder="https://your-api-gateway.execute-api.region.amazonaws.com/dev">
187
+ <small class="input-help">
188
+ Auto-populated from ?api, ?url, or ?signaling query parameters. Enter base API Gateway URL (without /signaling path).
189
+ </small>
190
+ </div>
191
+ <div class="input-group">
192
+ <label for="min-peers">Minimum Peers:</label>
193
+ <input type="number" id="min-peers"
194
+ min="0" max="49" value="2"
195
+ placeholder="Minimum peer connections to maintain">
196
+ <small class="input-help">
197
+ Minimum peer connections to maintain (0-49, default: 2)
198
+ </small>
199
+ </div>
200
+ <div class="input-group">
201
+ <label for="max-peers">Maximum Peers:</label>
202
+ <input type="number" id="max-peers"
203
+ min="1" max="50" value="10"
204
+ placeholder="Maximum number of peer connections">
205
+ <small class="input-help">
206
+ Limit concurrent peer connections (1-50, default: 10)
207
+ </small>
208
+ </div>
209
+ <div class="auto-discovery-control">
210
+ <label class="checkbox-label">
211
+ <input type="checkbox" id="xor-routing-toggle" checked>
212
+ <span class="checkmark"></span>
213
+ Enable XOR-based routing
214
+ </label>
215
+ <small class="input-help">
216
+ Use XOR distance for peer selection and routing optimization
217
+ </small>
218
+ </div>
219
+ <div class="auto-discovery-control">
220
+ <label class="checkbox-label">
221
+ <input type="checkbox" id="auto-discovery-toggle" checked>
222
+ <span class="checkmark"></span>
223
+ Enable automatic peer discovery
224
+ </label>
225
+ <small class="input-help">
226
+ Automatically discover and connect to nearby peers
227
+ </small>
228
+ </div>
229
+ <div class="auto-discovery-control">
230
+ <label class="checkbox-label">
231
+ <input type="checkbox" id="eviction-strategy-toggle" checked>
232
+ <span class="checkmark"></span>
233
+ Enable smart eviction strategy
234
+ </label>
235
+ <small class="input-help">
236
+ Automatically manage peer connections when at capacity
237
+ </small>
238
+ </div>
239
+ <div class="auto-discovery-control">
240
+ <label class="checkbox-label">
241
+ <input type="checkbox" id="webdht-toggle" checked disabled>
242
+ <span class="checkmark"></span>
243
+ Enable WebDHT (Distributed Hash Table)
244
+ </label>
245
+ <small class="input-help">
246
+ WebDHT status (configured at startup, restart required to change)
247
+ </small>
248
+ </div>
249
+ </div>
250
+ </div>
251
+
252
+ <div class="dht" aria-expanded="false">
253
+ <div class="section-header">
254
+ <h2>
255
+ <button id="dht-toggle" class="toggle-btn" aria-expanded="false">
256
+ ▶ WebDHT - Distributed Hash Table
257
+ </button>
258
+ </h2>
259
+ </div>
260
+ <div id="dht-content" class="collapsible-content" style="display: none;">
261
+ <div class="dht-actions">
262
+ <h3>Store Data</h3>
263
+ <div class="input-group">
264
+ <label for="dht-key">Key:</label>
265
+ <input type="text" id="dht-key" placeholder="Enter key (e.g., 'user:123', 'config:theme')">
266
+ </div>
267
+ <div class="input-group">
268
+ <label for="dht-value">Value:</label>
269
+ <textarea id="dht-value" placeholder="Enter value (JSON, text, etc.)" rows="3"></textarea>
270
+ </div>
271
+ <div class="input-group">
272
+ <label class="checkbox-label">
273
+ <input type="checkbox" id="dht-enable-ttl">
274
+ <span class="checkmark"></span>
275
+ Enable expiration (TTL)
276
+ </label>
277
+ <small class="input-help">
278
+ Check to set an expiration time, unchecked = records persist forever
279
+ </small>
280
+ </div>
281
+ <div class="input-group" id="dht-ttl-group" style="display: none;">
282
+ <label for="dht-ttl">TTL (seconds):</label>
283
+ <input type="number" id="dht-ttl" placeholder="Time to live" min="1" max="2592000" value="3600">
284
+ <small class="input-help">
285
+ Time until record expires (e.g., 3600 = 1 hour, 86400 = 1 day)
286
+ </small>
287
+ </div>
288
+ <div class="button-group">
289
+ <button id="dht-put-btn" class="btn primary">Store in DHT</button>
290
+ <button id="dht-update-btn" class="btn secondary">Update in DHT</button>
291
+ </div>
292
+ </div>
293
+
294
+ <div class="dht-actions">
295
+ <h3>Retrieve Data</h3>
296
+ <div class="input-group horizontal">
297
+ <input type="text" id="dht-get-key" placeholder="Enter key to retrieve">
298
+ <button id="dht-get-btn" class="btn secondary">Get from DHT</button>
299
+ </div>
300
+ </div>
301
+
302
+ <div class="dht-actions">
303
+ <h3>Subscribe to Changes</h3>
304
+ <div class="input-group horizontal">
305
+ <input type="text" id="dht-subscribe-key" placeholder="Key to watch for changes">
306
+ <div class="button-group">
307
+ <button id="dht-subscribe-btn" class="btn tertiary">Subscribe</button>
308
+ <button id="dht-clear-subscriptions-btn" class="btn quaternary">Clear All</button>
309
+ </div>
310
+ </div>
311
+ <div id="dht-subscriptions" class="dht-subscriptions">
312
+ <h4>Active Subscriptions:</h4>
313
+ <div id="dht-subscriptions-list" class="subscriptions-list">
314
+ <p class="empty-state">No active subscriptions</p>
315
+ </div>
316
+ </div>
317
+ </div>
318
+
319
+ <div class="dht-results">
320
+ <h3>DHT Operations Log</h3>
321
+ <div id="dht-log" class="dht-log"></div>
322
+ </div>
323
+ </div>
324
+ </div>
325
+
326
+ <div class="messages">
327
+ <h2>Messages</h2>
328
+ <div class="input-group horizontal">
329
+ <input type="text" id="message-input" placeholder="Enter message">
330
+ <input type="text" id="dm-target-input" placeholder="Peer ID for DM (leave blank to broadcast)" maxlength="40" pattern="[a-fA-F0-9]{40}">
331
+ <button id="send-message-btn" class="btn primary">Send</button>
332
+ </div>
333
+ <small class="input-help">To send a direct message, enter a 40-character peer ID. Leave blank to broadcast.</small>
334
+ <div id="messages-log" class="messages-log"></div>
335
+ </div>
336
+ </div>
337
+
338
+ <script type="module" src="app.js?v=20250704"></script>
339
+ </body>
340
+ </html>