lanet 0.2.1 → 0.4.0

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.
data/index.html CHANGED
@@ -7,122 +7,155 @@
7
7
  <style>
8
8
  body {
9
9
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
10
- line-height: 1.6;
11
- color: #333;
12
- max-width: 900px;
13
- margin: 0 auto;
10
+ line-height: 1.7; /* Increased line height for better readability */
11
+ color: #34495e; /* Darker, more professional text color */
12
+ max-width: 980px; /* Slightly wider max width for content */
13
+ margin: 20px auto; /* Added top and bottom margin for better spacing */
14
14
  padding: 20px;
15
- background-color: #f9f9f9;
15
+ background-color: #f4f6f9; /* Lighter background color */
16
16
  }
17
17
  h1 {
18
- color: #2c3e50;
19
- border-bottom: 2px solid #3498db;
20
- padding-bottom: 10px;
18
+ color: #34495e; /* Darker heading color */
19
+ border-bottom: 3px solid #3498db; /* Thicker border */
20
+ padding-bottom: 12px; /* Increased padding */
21
+ letter-spacing: -0.5px; /* Slightly tighter letter spacing for headings */
21
22
  }
22
23
  h2 {
23
- color: #2980b9;
24
- margin-top: 30px;
24
+ color: #3498db; /* Primary blue color for subheadings */
25
+ margin-top: 35px; /* Increased top margin */
26
+ margin-bottom: 10px; /* Added bottom margin */
25
27
  }
26
28
  h3 {
27
- color: #16a085;
28
- margin-top: 25px;
29
+ color: #2ecc71; /* Vibrant green for section titles */
30
+ margin-top: 30px;
31
+ margin-bottom: 8px;
29
32
  }
30
33
  h4 {
31
- color: #27ae60;
32
- margin-top: 20px;
34
+ color: #34495e; /* Darker color for sub-subheadings */
35
+ margin-top: 25px;
36
+ margin-bottom: 5px;
37
+ }
38
+ p {
39
+ margin-bottom: 15px; /* Increased paragraph spacing */
40
+ color: #555; /* Slightly softer paragraph text color */
41
+ }
42
+ ul, ol {
43
+ margin-bottom: 15px;
44
+ color: #555;
33
45
  }
34
46
  pre {
35
- background-color: #f8f8f8;
36
- border: 1px solid #ddd;
37
- border-left: 3px solid #3498db;
38
- padding: 15px;
47
+ background-color: #f0f0f0; /* Slightly darker pre background */
48
+ border: 1px solid #ccc; /* Lighter border */
49
+ border-left: 5px solid #3498db; /* Thicker, more prominent left border */
50
+ padding: 16px; /* Increased padding */
39
51
  overflow-x: auto;
40
- border-radius: 4px;
52
+ border-radius: 6px; /* More rounded corners */
53
+ font-size: 0.95em; /* Slightly smaller font size in code blocks */
41
54
  }
42
55
  code {
43
56
  font-family: 'Courier New', Courier, monospace;
57
+ color: #2c3e50; /* Darker code text color */
44
58
  }
45
59
  .container {
46
60
  background-color: #fff;
47
- border-radius: 8px;
48
- box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
49
- padding: 30px;
61
+ border-radius: 10px; /* More rounded container corners */
62
+ box-shadow: 0 3px 20px rgba(0, 0, 0, 0.08); /* Softer, more subtle shadow */
63
+ padding: 40px; /* Increased container padding */
50
64
  }
51
65
  .feature {
52
- margin: 20px 0;
53
- padding-left: 20px;
54
- border-left: 4px solid #2ecc71;
66
+ margin: 25px 0; /* Increased feature margin */
67
+ padding-left: 25px; /* Increased padding */
68
+ border-left: 5px solid #2ecc71; /* Thicker feature border */
55
69
  }
56
70
  .security-feature {
57
71
  background-color: #e8f4fc;
58
- padding: 15px;
59
- margin: 10px 0;
60
- border-radius: 6px;
72
+ padding: 20px; /* Increased padding */
73
+ margin: 15px 0; /* Increased margin */
74
+ border-radius: 8px; /* More rounded corners */
75
+ }
76
+ .security-feature ul li {
77
+ margin-bottom: 8px; /* Spacing in security feature lists */
61
78
  }
62
79
  .cli-example {
63
80
  background-color: #2c3e50;
64
81
  color: #ecf0f1;
65
- padding: 12px 18px;
66
- margin: 10px 0;
67
- border-radius: 6px;
82
+ padding: 15px 20px; /* Increased padding */
83
+ margin: 15px 0; /* Increased margin */
84
+ border-radius: 8px; /* More rounded corners */
68
85
  font-family: 'Courier New', Courier, monospace;
69
86
  position: relative;
87
+ font-size: 0.95em; /* Slightly smaller font size in CLI examples */
70
88
  }
71
89
  .cli-example::before {
72
90
  content: "$";
73
91
  color: #3498db;
74
- margin-right: 10px;
92
+ margin-right: 12px; /* Increased margin */
75
93
  font-weight: bold;
94
+ display: inline-block; /* Ensure proper spacing */
95
+ width: 15px; /* Fixed width for the dollar sign to align commands */
96
+ text-align: right; /* Align dollar sign to the right */
76
97
  }
77
98
  .cli-section {
78
- margin-bottom: 30px;
99
+ margin-bottom: 40px; /* Increased bottom margin */
79
100
  background-color: #f8f9fa;
80
- padding: 20px;
81
- border-radius: 6px;
101
+ padding: 25px; /* Increased padding */
102
+ border-radius: 8px; /* More rounded corners */
82
103
  }
83
104
  .output-example {
84
105
  background-color: #f0f0f0;
85
- padding: 12px;
86
- margin: 10px 0;
87
- border-radius: 6px;
106
+ padding: 15px; /* Increased padding */
107
+ margin: 15px 0; /* Increased margin */
108
+ border-radius: 8px; /* More rounded corners */
88
109
  font-family: 'Courier New', Courier, monospace;
89
110
  font-size: 0.9em;
90
- border-left: 3px solid #9b59b6;
111
+ border-left: 5px solid #9b59b6; /* Thicker border */
91
112
  }
92
113
  .tab-container {
93
114
  border: 1px solid #ddd;
94
- border-radius: 6px;
115
+ border-radius: 8px; /* More rounded corners */
95
116
  overflow: hidden;
96
- margin: 20px 0;
117
+ margin: 25px 0; /* Increased margin */
97
118
  }
98
119
  .tab-buttons {
99
120
  display: flex;
100
121
  background-color: #f5f5f5;
122
+ border-bottom: 1px solid #ddd; /* Added bottom border to tab buttons container */
101
123
  }
102
124
  .tab-button {
103
- padding: 10px 20px;
125
+ padding: 12px 25px; /* Increased padding */
104
126
  background-color: transparent;
105
127
  border: none;
106
128
  cursor: pointer;
107
- border-right: 1px solid #ddd;
129
+ border-right: none; /* Removed right border */
108
130
  transition: background-color 0.3s;
131
+ font-weight: 500; /* Slightly bolder tab button text */
132
+ color: #777; /* Slightly muted tab button text color */
109
133
  }
110
- .tab-button:hover, .tab-button.active {
111
- background-color: #e0e0e0;
134
+ .tab-button:hover {
135
+ background-color: #f0f0f0; /* Lighter hover background */
136
+ color: #555; /* Darker hover text color */
137
+ }
138
+ .tab-button.active {
139
+ background-color: #fff; /* White background for active tab */
140
+ border-bottom: 3px solid #3498db; /* Underline for active tab */
141
+ color: #34495e; /* Darker text for active tab */
142
+ font-weight: bold; /* Bold text for active tab */
112
143
  }
113
144
  .tab-content {
114
145
  display: none;
115
- padding: 15px;
146
+ padding: 20px; /* Increased padding */
147
+ background-color: #fff; /* White background for tab content */
116
148
  }
117
149
  .tab-content.active {
118
150
  display: block;
119
151
  }
120
152
  .badge {
121
153
  display: inline-block;
122
- padding: 3px 8px;
123
- border-radius: 4px;
124
- font-size: 12px;
125
- font-weight: bold;
154
+ padding: 4px 10px; /* Increased badge padding */
155
+ border-radius: 6px; /* More rounded corners */
156
+ font-size: 13px; /* Slightly larger font size */
157
+ font-weight: 600; /* Bolder badge text */
158
+ letter-spacing: 0.5px; /* Added letter spacing */
126
159
  }
127
160
  .badge-new {
128
161
  background-color: #2ecc71;
@@ -130,10 +163,25 @@
130
163
  }
131
164
  .note {
132
165
  background-color: #fff8e1;
133
- padding: 12px;
134
- border-left: 4px solid #ffc107;
135
- margin: 10px 0;
136
- border-radius: 4px;
166
+ padding: 15px; /* Increased padding */
167
+ border-left: 5px solid #ffc107; /* Thicker border */
168
+ margin: 15px 0; /* Increased margin */
169
+ border-radius: 6px; /* More rounded corners */
170
+ }
171
+ .note strong {
172
+ font-weight: bold;
173
+ color: #333; /* Make "Note:" bold and slightly darker */
174
+ }
175
+ footer {
176
+ margin-top: 50px; /* Increased footer margin */
177
+ text-align: center;
178
+ color: #7f8c8d;
179
+ padding-top: 20px;
180
+ border-top: 1px solid #ddd; /* Added top border to footer */
181
+ }
182
+ footer p {
183
+ color: #95a5a6; /* Softer footer text color */
184
+ font-size: 0.9em; /* Smaller footer font size */
137
185
  }
138
186
  </style>
139
187
  </head>
@@ -141,18 +189,18 @@
141
189
  <div class="container">
142
190
  <h1>Lanet</h1>
143
191
  <p>A secure network communication library that enables reliable and protected message exchange between devices on the same network.</p>
144
-
192
+
145
193
  <h2>Key Features</h2>
146
-
194
+
147
195
  <div class="feature">
148
196
  <h3>Encrypted Communication</h3>
149
197
  <p>Protect your messages with AES-256-CBC encryption to ensure confidentiality during transmission.</p>
150
198
  </div>
151
-
199
+
152
200
  <div class="feature">
153
- <h3>Digital Signatures <span class="badge badge-new">New in v0.2.0</span></h3>
201
+ <h3>Digital Signatures <span class="badge badge-new">New in v0.2.1</span></h3>
154
202
  <p>Verify message authenticity and integrity with RSA-based digital signatures.</p>
155
-
203
+
156
204
  <div class="security-feature">
157
205
  <h4>Benefits of Digital Signatures:</h4>
158
206
  <ul>
@@ -163,37 +211,58 @@
163
211
  </ul>
164
212
  </div>
165
213
  </div>
166
-
214
+
167
215
  <div class="feature">
168
216
  <h3>Network Discovery</h3>
169
217
  <p>Automatically find active devices on your local network with advanced scanning capabilities.</p>
170
218
  </div>
171
-
219
+
172
220
  <div class="feature">
173
221
  <h3>Broadcasting</h3>
174
222
  <p>Send messages to all devices on your network simultaneously.</p>
175
223
  </div>
176
224
 
225
+ <div class="feature">
226
+ <h3>File Transfer <span class="badge badge-new">New in v0.3.0</span></h3>
227
+ <p>Securely transfer files between devices with encryption, digital signatures, and integrity verification.</p>
228
+ </div>
229
+
230
+ <div class="feature">
231
+ <h3>Mesh Networking <span class="badge badge-new">New in v0.4.0</span></h3>
232
+ <p>Create resilient, decentralized mesh networks that enable communication between devices even without direct connectivity.</p>
233
+
234
+ <div class="security-feature">
235
+ <h4>Benefits of Mesh Networking:</h4>
236
+ <ul>
237
+ <li><strong>Decentralization</strong>: No central server or infrastructure needed</li>
238
+ <li><strong>Resilience</strong>: Messages can route around failed nodes or connections</li>
239
+ <li><strong>Extended Range</strong>: Devices can communicate beyond direct connection range</li>
240
+ <li><strong>Scalability</strong>: Network grows stronger with more participating nodes</li>
241
+ <li><strong>Self-healing</strong>: Network automatically adapts to changing conditions</li>
242
+ </ul>
243
+ </div>
244
+ </div>
245
+
177
246
  <h2>Command Line Interface</h2>
178
247
 
179
248
  <div class="note">
180
249
  <strong>Note:</strong> All Lanet commands have detailed help available. Try <code>lanet [command] --help</code> for more options.
181
250
  </div>
182
-
251
+
183
252
  <div class="cli-section">
184
- <h3>Digital Signature Commands <span class="badge badge-new">New in v0.2.0</span></h3>
185
-
253
+ <h3>Digital Signature Commands <span class="badge badge-new">New in v0.2.1</span></h3>
254
+
186
255
  <h4>Generate a Key Pair</h4>
187
256
  <p>Create RSA keys for signing and verifying messages:</p>
188
257
  <div class="cli-example">
189
258
  lanet keygen
190
259
  </div>
191
-
260
+
192
261
  <p>Generate keys with custom options:</p>
193
262
  <div class="cli-example">
194
263
  lanet keygen --bits 4096 --output ~/.lanet_keys
195
264
  </div>
196
-
265
+
197
266
  <div class="output-example">
198
267
  Key pair generated!
199
268
  Private key saved to: /home/user/.lanet_keys/lanet_private.key
@@ -202,32 +271,32 @@ Public key saved to: /home/user/.lanet_keys/lanet_public.key
202
271
  IMPORTANT: Keep your private key secure and never share it.
203
272
  Share your public key with others who need to verify your messages.
204
273
  </div>
205
-
274
+
206
275
  <h4>Send a Signed Message</h4>
207
276
  <div class="cli-example">
208
277
  lanet send --target 192.168.1.5 --message "Signed message" --private-key-file lanet_private.key
209
278
  </div>
210
-
279
+
211
280
  <h4>Send a Signed & Encrypted Message</h4>
212
281
  <div class="cli-example">
213
282
  lanet send --target 192.168.1.5 --message "Secure signed message" --key "my_secret_key" --private-key-file lanet_private.key
214
283
  </div>
215
-
284
+
216
285
  <h4>Broadcast a Signed Message</h4>
217
286
  <div class="cli-example">
218
287
  lanet broadcast --message "Important announcement" --private-key-file lanet_private.key
219
288
  </div>
220
-
289
+
221
290
  <h4>Listen for and Verify Signed Messages</h4>
222
291
  <div class="cli-example">
223
292
  lanet listen --public-key-file lanet_public.key
224
293
  </div>
225
-
294
+
226
295
  <h4>Listen for Encrypted & Signed Messages</h4>
227
296
  <div class="cli-example">
228
297
  lanet listen --encryption-key "my_secret_key" --public-key-file lanet_public.key
229
298
  </div>
230
-
299
+
231
300
  <p>Example output when receiving a signed message:</p>
232
301
  <div class="output-example">
233
302
  Message from 192.168.1.5:
@@ -239,27 +308,27 @@ Signature: ✓ VERIFIED
239
308
 
240
309
  <div class="cli-section">
241
310
  <h3>Basic Message Commands</h3>
242
-
311
+
243
312
  <h4>Send a Message</h4>
244
313
  <div class="cli-example">
245
314
  lanet send --target 192.168.1.5 --message "Hello there!"
246
315
  </div>
247
-
316
+
248
317
  <h4>Send an Encrypted Message</h4>
249
318
  <div class="cli-example">
250
319
  lanet send --target 192.168.1.5 --message "Secret message" --key "my_secret_key"
251
320
  </div>
252
-
321
+
253
322
  <h4>Broadcast a Message</h4>
254
323
  <div class="cli-example">
255
324
  lanet broadcast --message "Announcement for everyone!"
256
325
  </div>
257
-
326
+
258
327
  <h4>Listen for Messages</h4>
259
328
  <div class="cli-example">
260
329
  lanet listen
261
330
  </div>
262
-
331
+
263
332
  <h4>Listen for Encrypted Messages</h4>
264
333
  <div class="cli-example">
265
334
  lanet listen --encryption-key "my_secret_key"
@@ -268,33 +337,106 @@ Signature: ✓ VERIFIED
268
337
 
269
338
  <div class="cli-section">
270
339
  <h3>Network Discovery Commands</h3>
271
-
340
+
272
341
  <h4>Scan Network</h4>
273
342
  <div class="cli-example">
274
343
  lanet scan --range 192.168.1.0/24
275
344
  </div>
276
-
345
+
277
346
  <h4>Detailed Network Scan</h4>
278
347
  <div class="cli-example">
279
348
  lanet scan --range 192.168.1.0/24 --verbose --threads 16 --timeout 2
280
349
  </div>
281
-
350
+
282
351
  <h4>Ping a Host</h4>
283
352
  <div class="cli-example">
284
353
  lanet ping 192.168.1.5
285
354
  </div>
286
-
355
+
287
356
  <h4>Continuous Ping</h4>
288
357
  <div class="cli-example">
289
358
  lanet ping 192.168.1.5 --continuous
290
359
  </div>
291
-
360
+
292
361
  <h4>Ping Multiple Hosts</h4>
293
362
  <div class="cli-example">
294
363
  lanet ping --hosts 192.168.1.5,192.168.1.6,192.168.1.7 --count 5
295
364
  </div>
296
365
  </div>
297
-
366
+
367
+ <div class="cli-section">
368
+ <h3>File Transfer Commands <span class="badge badge-new">New in v0.3.0</span></h3>
369
+
370
+ <h4>Send a File</h4>
371
+ <p>Send a file with encryption:</p>
372
+ <div class="cli-example">
373
+ lanet send-file --target 192.168.1.5 --file document.pdf --key "my_secret_key"
374
+ </div>
375
+
376
+ <p>Send a file with encryption and digital signature:</p>
377
+ <div class="cli-example">
378
+ lanet send-file --target 192.168.1.5 --file document.pdf --key "my_secret_key" --private-key-file lanet_private.key
379
+ </div>
380
+
381
+ <h4>Receive Files</h4>
382
+ <div class="cli-example">
383
+ lanet receive-file --output ./downloads --encryption-key "my_secret_key"
384
+ </div>
385
+
386
+ <p>With signature verification:</p>
387
+ <div class="cli-example">
388
+ lanet receive-file --output ./downloads --encryption-key "my_secret_key" --public-key-file lanet_public.key
389
+ </div>
390
+
391
+ <p>Example output during file transfer:</p>
392
+ <div class="output-example">
393
+ Receiving file: document.pdf from 192.168.1.5
394
+ Size: 1048576 bytes
395
+ Transfer ID: 8a7b6c5d-4e3f-2g1h-0i9j-8k7l6m5n4o3p
396
+ Progress: 75% (786432/1048576 bytes)
397
+ </div>
398
+ </div>
399
+
400
+ <div class="cli-section">
401
+ <h3>Mesh Network Commands <span class="badge badge-new">New in v0.4.0</span></h3>
402
+
403
+ <h4>Start a Mesh Network Node</h4>
404
+ <div class="cli-example">
405
+ lanet mesh start
406
+ </div>
407
+
408
+ <h4>Start with Custom Settings</h4>
409
+ <div class="cli-example">
410
+ lanet mesh start --port 5050 --max-hops 15
411
+ </div>
412
+
413
+ <h4>Send a Message Through the Mesh</h4>
414
+ <div class="cli-example">
415
+ lanet mesh send --target a1b2c3d4-5678-90ef-ghij --message "Hello Mesh"
416
+ </div>
417
+
418
+ <h4>Send an Encrypted Mesh Message</h4>
419
+ <div class="cli-example">
420
+ lanet mesh send --target a1b2c3d4-5678-90ef-ghij --message "Secret mesh message" --key "secret-key"
421
+ </div>
422
+
423
+ <h4>View Mesh Network Information</h4>
424
+ <div class="cli-example">
425
+ lanet mesh info
426
+ </div>
427
+
428
+ <p>Example output when viewing mesh info:</p>
429
+ <div class="output-example">
430
+ Mesh Node ID: 4f9a8b7c-6d5e-4f3e-2d1c-0b9a8b7c6d5e
431
+
432
+ Connected nodes:
433
+ b1c2d3e4-f5g6-7h8i-9j0k-l1m2n3o4p5q6 (192.168.1.5, last seen 12s ago)
434
+ c5d4e3f2-g1h0-i9j8-k7l6-m5n4o3p2q1r0 (192.168.1.10, last seen 5s ago)
435
+
436
+ Message cache: 24 messages
437
+ </div>
438
+ </div>
439
+
298
440
  <h2>Ruby Code Examples</h2>
299
441
 
300
442
  <div class="tab-container">
@@ -302,8 +444,10 @@ Signature: ✓ VERIFIED
302
444
  <button class="tab-button active" onclick="openTab(event, 'tab-basic')">Basic Usage</button>
303
445
  <button class="tab-button" onclick="openTab(event, 'tab-signatures')">Digital Signatures</button>
304
446
  <button class="tab-button" onclick="openTab(event, 'tab-advanced')">Advanced Usage</button>
447
+ <button class="tab-button" onclick="openTab(event, 'tab-filetransfer')">File Transfer</button>
448
+ <button class="tab-button" onclick="openTab(event, 'tab-mesh')">Mesh Network</button>
305
449
  </div>
306
-
450
+
307
451
  <div id="tab-basic" class="tab-content active">
308
452
  <pre><code>require 'lanet'
309
453
 
@@ -322,7 +466,7 @@ encrypted = Lanet::Encryptor.prepare_message('Secret message', 'my_encryption_ke
322
466
  # Send the encrypted message
323
467
  sender.send_to('192.168.1.5', encrypted)</code></pre>
324
468
  </div>
325
-
469
+
326
470
  <div id="tab-signatures" class="tab-content">
327
471
  <pre><code>require 'lanet'
328
472
 
@@ -338,8 +482,8 @@ encryption_key = "secret-key-123"
338
482
  # Send a signed and encrypted message
339
483
  message = "Hello, secure world!"
340
484
  prepared_message = Lanet::Encryptor.prepare_message(
341
- message,
342
- encryption_key,
485
+ message,
486
+ encryption_key,
343
487
  private_key
344
488
  )
345
489
  sender.send_to("192.168.1.5", prepared_message)
@@ -348,17 +492,17 @@ sender.send_to("192.168.1.5", prepared_message)
348
492
  receiver = Lanet::Receiver.new(9000)
349
493
  receiver.listen do |data, sender_ip|
350
494
  result = Lanet::Encryptor.process_message(
351
- data,
352
- encryption_key,
495
+ data,
496
+ encryption_key,
353
497
  public_key
354
498
  )
355
-
499
+
356
500
  puts "Message: #{result[:content]}"
357
501
  puts "Verified: #{result[:verified]}"
358
502
  puts "Verification status: #{result[:verification_status]}"
359
503
  end</code></pre>
360
504
  </div>
361
-
505
+
362
506
  <div id="tab-advanced" class="tab-content">
363
507
  <pre><code>require 'lanet'
364
508
 
@@ -369,7 +513,7 @@ active_hosts = scanner.scan('192.168.1.0/24', 1, 32, true)
369
513
  active_hosts.each do |host|
370
514
  puts "Host: #{host[:ip]}, Hostname: #{host[:hostname]}"
371
515
  puts "Response time: #{host[:response_time]}ms"
372
-
516
+
373
517
  if host[:ports]
374
518
  puts "Open ports:"
375
519
  host[:ports].each do |port, service|
@@ -388,47 +532,135 @@ puts "Response time: #{result[:response_time]}ms"
388
532
  encryption_key = "network-shared-key"
389
533
  message = "Important system notification"
390
534
  signed_message = Lanet::Encryptor.prepare_message(
391
- message,
392
- encryption_key,
535
+ message,
536
+ encryption_key,
393
537
  private_key
394
538
  )
395
539
  sender.broadcast(signed_message)</code></pre>
396
540
  </div>
541
+
542
+ <div id="tab-filetransfer" class="tab-content">
543
+ <pre><code>require 'lanet'
544
+
545
+ # Create a file transfer instance
546
+ file_transfer = Lanet.file_transfer
547
+
548
+ # Send a file with encryption
549
+ file_transfer.send_file(
550
+ '192.168.1.5',
551
+ 'document.pdf',
552
+ 'encryption_key'
553
+ ) do |progress, bytes, total|
554
+ puts "Progress: #{progress}% (#{bytes}/#{total} bytes)"
555
+ end
556
+
557
+ # Send a file with encryption and digital signature
558
+ key_pair = Lanet::Signer.generate_key_pair
559
+ file_transfer.send_file(
560
+ '192.168.1.5',
561
+ 'document.pdf',
562
+ 'encryption_key',
563
+ key_pair[:private_key]
564
+ )
565
+
566
+ # Receive files
567
+ file_transfer.receive_file('./downloads', 'encryption_key') do |event, data|
568
+ case event
569
+ when :start
570
+ puts "Receiving file: #{data[:file_name]}"
571
+ puts "From: #{data[:sender_ip]}"
572
+ puts "Size: #{data[:file_size]} bytes"
573
+ when :progress
574
+ puts "Progress: #{data[:progress]}%"
575
+ when :complete
576
+ puts "File saved to: #{data[:file_path]}"
577
+ when :error
578
+ puts "Error: #{data[:error]}"
579
+ end
580
+ end</code></pre>
581
+ </div>
582
+
583
+ <div id="tab-mesh" class="tab-content">
584
+ <pre><code>require 'lanet'
585
+
586
+ # Create and start a mesh network node
587
+ mesh = Lanet.mesh_network
588
+ mesh.start
589
+
590
+ puts "Mesh node started with ID: #{mesh.node_id}"
591
+
592
+ # Send a plain message through the mesh
593
+ begin
594
+ message_id = mesh.send_message(
595
+ "target-node-id-here",
596
+ "Hello through the mesh network!"
597
+ )
598
+ puts "Message sent with ID: #{message_id}"
599
+ rescue Lanet::Mesh::Error => e
600
+ puts "Message sending failed: #{e.message}"
601
+ end
602
+
603
+ # Send an encrypted and signed message
604
+ encryption_key = "mesh-encryption-key"
605
+ key_pair = Lanet::Signer.generate_key_pair
606
+ private_key = key_pair[:private_key]
607
+
608
+ begin
609
+ message_id = mesh.send_message(
610
+ "target-node-id-here",
611
+ "Secure mesh message",
612
+ encryption_key,
613
+ private_key
614
+ )
615
+ puts "Secure message sent with ID: #{message_id}"
616
+ rescue Lanet::Mesh::Error => e
617
+ puts "Secure message sending failed: #{e.message}"
618
+ end
619
+
620
+ # Examine mesh connections
621
+ puts "Connected to #{mesh.connections.size} nodes:"
622
+ mesh.connections.each do |node_id, info|
623
+ puts " • #{node_id} (#{info[:ip]}, last seen #{Time.now.to_i - info[:last_seen]}s ago)"
624
+ end
625
+
626
+ # Always stop the mesh node when done
627
+ mesh.stop</code></pre>
628
+ </div>
397
629
  </div>
398
-
630
+
399
631
  <h2>Installation</h2>
400
-
632
+
401
633
  <p>Add this to your Gemfile:</p>
402
634
  <pre><code>gem 'lanet'</code></pre>
403
-
635
+
404
636
  <p>Or install directly:</p>
405
637
  <pre><code>gem install lanet</code></pre>
406
-
638
+
407
639
  <h2>Documentation</h2>
408
640
  <p>For complete documentation, please visit the <a href="https://github.com/davidesantangelo/lanet">GitHub repository</a>.</p>
409
-
641
+
410
642
  <footer style="margin-top: 40px; text-align: center; color: #7f8c8d;">
411
- <p>Lanet v0.2.0 - Secure Network Communications Library</p>
643
+ <p>Lanet v0.4.0 - Secure Network Communications Library</p>
412
644
  </footer>
413
645
  </div>
414
646
 
415
647
  <script>
416
648
  function openTab(evt, tabName) {
417
649
  var i, tabContent, tabButtons;
418
-
650
+
419
651
  tabContent = document.getElementsByClassName("tab-content");
420
652
  for (i = 0; i < tabContent.length; i++) {
421
653
  tabContent[i].className = tabContent[i].className.replace(" active", "");
422
654
  }
423
-
655
+
424
656
  tabButtons = document.getElementsByClassName("tab-button");
425
657
  for (i = 0; i < tabButtons.length; i++) {
426
658
  tabButtons[i].className = tabButtons[i].className.replace(" active", "");
427
659
  }
428
-
660
+
429
661
  document.getElementById(tabName).className += " active";
430
662
  evt.currentTarget.className += " active";
431
663
  }
432
664
  </script>
433
665
  </body>
434
- </html>
666
+ </html>