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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -0
- data/Gemfile.lock +1 -1
- data/README.md +228 -16
- data/index.html +336 -104
- data/lib/lanet/cli.rb +183 -14
- data/lib/lanet/file_transfer.rb +315 -0
- data/lib/lanet/mesh.rb +493 -0
- data/lib/lanet/version.rb +1 -1
- data/lib/lanet.rb +42 -27
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1e22dfda5b58811a99f1d763c3ff32d84b2e8e291ab07b8f1ee90e3c1849446
|
4
|
+
data.tar.gz: 70a12c6ea35bd5981acc401f0a7dc482c2f2161c2a67a8b4ffcefc00ac1777a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e45f31e4dacefa4d0622f1fdfe8d8cb48dca0c4ad256481a06f8bf7d1dea2ef231be657db2b8c92c1e129faa8375bdc36221152fb7967cca15ae7bc3c5fce89b
|
7
|
+
data.tar.gz: 4cceff6bc76a51aeebb0bc0585ec9228d53151421927e8e8461e39a79f0208ed3a793455f8b9e0714364ce9cb169e987ab757a29e7ad4ab3acc908ab72f8a11f
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,29 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
## [0.4.0] - 2023-11-15
|
9
|
+
|
10
|
+
### Added
|
11
|
+
- Mesh networking functionality for decentralized communication
|
12
|
+
- Auto-discovery of mesh nodes
|
13
|
+
- Message routing through intermediate nodes
|
14
|
+
- CLI commands for mesh network operations: `mesh start`, `mesh send`, `mesh info`
|
15
|
+
- Ruby API methods for creating and managing mesh networks
|
16
|
+
|
17
|
+
## [0.3.0] - 2025-03-08
|
18
|
+
|
19
|
+
### Added
|
20
|
+
- Encrypted file transfer support over LAN
|
21
|
+
- New `FileTransfer` class for sending and receiving files securely
|
22
|
+
- CLI commands for file transfer operations:
|
23
|
+
- `send-file` - Send a file to a specific target
|
24
|
+
- `receive-file` - Listen for incoming files
|
25
|
+
- Progress tracking for file transfers
|
26
|
+
- File integrity verification via SHA-256 checksums
|
27
|
+
- Support for digital signatures in file transfers
|
28
|
+
- File chunking for efficient transfer of large files
|
29
|
+
- Comprehensive documentation and examples
|
30
|
+
|
8
31
|
## [0.2.1] - 2025-03-07
|
9
32
|
|
10
33
|
### Fixed
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -8,16 +8,18 @@ A lightweight, powerful LAN communication tool that enables secure message excha
|
|
8
8
|
|
9
9
|
## Features
|
10
10
|
|
11
|
-
-
|
12
|
-
-
|
13
|
-
-
|
14
|
-
-
|
15
|
-
-
|
16
|
-
-
|
17
|
-
-
|
18
|
-
-
|
19
|
-
-
|
11
|
+
- **Simple API** - An intuitive Ruby interface makes network communication straightforward.
|
12
|
+
- **Built-in encryption** - Optional message encryption with AES-256-GCM for confidentiality.
|
13
|
+
- **Network scanning** - Automatically discover active devices on your local network.
|
14
|
+
- **Targeted messaging** - Send messages to specific IP addresses.
|
15
|
+
- **Broadcasting** - Send messages to all devices on the network.
|
16
|
+
- **Host pinging** - Check host availability and measure response times (with a familiar `ping` interface).
|
17
|
+
- **Command-line interface** - Perform common network operations directly from your terminal.
|
18
|
+
- **Extensible** - Easily build custom tools and integrations using the Lanet API.
|
19
|
+
- **Configurable:** Adjust port settings, encryption keys, and network scan ranges.
|
20
20
|
- **Digital Signatures**: Ensure message authenticity and integrity
|
21
|
+
- **File Transfers**: Securely send encrypted files over the LAN with progress tracking and integrity verification
|
22
|
+
- **Mesh Networking**: Create resilient mesh networks for decentralized communication, enabling messages to be routed through multiple hops without central infrastructure
|
21
23
|
|
22
24
|
## Security Features
|
23
25
|
|
@@ -266,6 +268,72 @@ Ping multiple hosts continuously:
|
|
266
268
|
lanet ping --hosts 192.168.1.5,192.168.1.6 --continuous
|
267
269
|
```
|
268
270
|
|
271
|
+
#### Sending Files Securely
|
272
|
+
|
273
|
+
Send files with encryption:
|
274
|
+
|
275
|
+
```bash
|
276
|
+
lanet send-file --target 192.168.1.5 --file document.pdf --key "my_secret_key"
|
277
|
+
```
|
278
|
+
|
279
|
+
Send files with encryption and digital signatures:
|
280
|
+
|
281
|
+
```bash
|
282
|
+
lanet send-file --target 192.168.1.5 --file document.pdf --key "my_secret_key" --private-key-file lanet_private.key
|
283
|
+
```
|
284
|
+
|
285
|
+
#### Receiving Files
|
286
|
+
|
287
|
+
Listen for incoming files:
|
288
|
+
|
289
|
+
```bash
|
290
|
+
lanet receive-file --output ./downloads
|
291
|
+
```
|
292
|
+
|
293
|
+
Receive encrypted files:
|
294
|
+
|
295
|
+
```bash
|
296
|
+
lanet receive-file --output ./downloads --encryption-key "my_secret_key"
|
297
|
+
```
|
298
|
+
|
299
|
+
Receive encrypted files with signature verification:
|
300
|
+
|
301
|
+
```bash
|
302
|
+
lanet receive-file --output ./downloads --encryption-key "my_secret_key" --public-key-file lanet_public.key
|
303
|
+
```
|
304
|
+
|
305
|
+
#### Mesh Networking
|
306
|
+
|
307
|
+
Create a decentralized mesh network where devices can communicate even without direct connectivity:
|
308
|
+
|
309
|
+
```bash
|
310
|
+
# Start a mesh network node
|
311
|
+
lanet mesh start
|
312
|
+
|
313
|
+
# Start a mesh network node with custom settings
|
314
|
+
lanet mesh start --port 5050 --max-hops 15
|
315
|
+
```
|
316
|
+
|
317
|
+
Send messages through the mesh network:
|
318
|
+
|
319
|
+
```bash
|
320
|
+
# Send a message through the mesh network to a specific node ID
|
321
|
+
lanet mesh send --target a1b2c3d4-5678-90ef-ghij --message "Hello Mesh Network"
|
322
|
+
|
323
|
+
# Send an encrypted message through the mesh network
|
324
|
+
lanet mesh send --target a1b2c3d4-5678-90ef-ghij --message "Secret mesh message" --key "secret-key"
|
325
|
+
|
326
|
+
# Send a signed message through the mesh network
|
327
|
+
lanet mesh send --target a1b2c3d4-5678-90ef-ghij --message "Authenticated mesh message" --private-key-file lanet_private.key
|
328
|
+
```
|
329
|
+
|
330
|
+
View information about your mesh network:
|
331
|
+
|
332
|
+
```bash
|
333
|
+
# Display information about mesh network connections
|
334
|
+
lanet mesh info
|
335
|
+
```
|
336
|
+
|
269
337
|
### Ruby API
|
270
338
|
|
271
339
|
You can also use Lanet programmatically in your Ruby applications:
|
@@ -340,8 +408,60 @@ end
|
|
340
408
|
|
341
409
|
# Ping multiple hosts continuously
|
342
410
|
pinger.ping_hosts(['192.168.1.5', '192.168.1.6'], true, true)
|
411
|
+
|
412
|
+
# Work with secure file transfers
|
413
|
+
file_transfer = Lanet.file_transfer
|
414
|
+
file_transfer.send_file('192.168.1.5', 'document.pdf', 'encryption_key') do |progress, bytes, total|
|
415
|
+
puts "Progress: #{progress}% (#{bytes}/#{total} bytes)"
|
416
|
+
end
|
417
|
+
|
418
|
+
# Receive files
|
419
|
+
file_transfer.receive_file('./downloads', 'encryption_key') do |event, data|
|
420
|
+
case event
|
421
|
+
when :start
|
422
|
+
puts "Receiving file: #{data[:file_name]} from #{data[:sender_ip]}"
|
423
|
+
when :progress
|
424
|
+
puts "Progress: #{data[:progress]}%"
|
425
|
+
when :complete
|
426
|
+
puts "File saved to: #{data[:file_path]}"
|
427
|
+
end
|
428
|
+
end
|
429
|
+
|
430
|
+
# Mesh Networking
|
431
|
+
mesh = Lanet.mesh_network
|
432
|
+
mesh.start # Start the mesh node and discovery service
|
433
|
+
|
434
|
+
# Send a message through the mesh network
|
435
|
+
mesh.send_message(target_node_id, "Hello through the mesh!", "optional-encryption-key")
|
436
|
+
|
437
|
+
# Get info about mesh connections
|
438
|
+
puts "Node ID: #{mesh.node_id}"
|
439
|
+
puts "Connected to #{mesh.connections.size} nodes"
|
440
|
+
mesh.connections.each do |node_id, info|
|
441
|
+
puts " #{node_id} (#{info[:ip]})"
|
442
|
+
end
|
443
|
+
|
444
|
+
# Properly stop the mesh node
|
445
|
+
mesh.stop
|
343
446
|
```
|
344
447
|
|
448
|
+
## Mesh Network
|
449
|
+
|
450
|
+
The mesh networking feature provides decentralized communication capabilities:
|
451
|
+
|
452
|
+
- **Auto-discovery**: Nodes automatically find each other on the network
|
453
|
+
- **Multi-hop routing**: Messages can be routed through intermediate nodes
|
454
|
+
- **Self-healing**: Adapts to changing network conditions and lost connections
|
455
|
+
- **Store and forward**: Messages persist until they can be delivered
|
456
|
+
- **End-to-end security**: Messages remain encrypted across multiple hops
|
457
|
+
- **Verification**: Digital signatures ensure message integrity through the mesh
|
458
|
+
|
459
|
+
Ideal for:
|
460
|
+
- IoT networks where devices may not have direct connectivity
|
461
|
+
- Ad-hoc networks without fixed infrastructure
|
462
|
+
- Networks requiring high resilience and redundancy
|
463
|
+
- Applications needing peer-to-peer communication
|
464
|
+
|
345
465
|
## Configuration
|
346
466
|
|
347
467
|
Lanet can be configured with several options:
|
@@ -487,14 +607,106 @@ end
|
|
487
607
|
# monitor.run_continuous_monitoring
|
488
608
|
```
|
489
609
|
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
610
|
+
## Use Case Example: Securely Sharing Files in a Team Environment
|
611
|
+
|
612
|
+
This example demonstrates how to use Lanet's file transfer capabilities to securely share files within a team:
|
613
|
+
|
614
|
+
```ruby
|
615
|
+
require 'lanet'
|
616
|
+
require 'fileutils'
|
617
|
+
|
618
|
+
class SecureTeamFileSharing
|
619
|
+
def initialize(team_key, keys_dir = '~/.lanet_keys')
|
620
|
+
@team_key = team_key
|
621
|
+
@keys_dir = File.expand_path(keys_dir)
|
622
|
+
@transfer = Lanet.file_transfer
|
623
|
+
|
624
|
+
# Ensure keys directory exists
|
625
|
+
FileUtils.mkdir_p(@keys_dir) unless Dir.exist?(@keys_dir)
|
626
|
+
|
627
|
+
# Generate keys if they don't exist
|
628
|
+
unless File.exist?(private_key_path) && File.exist?(public_key_path)
|
629
|
+
puts "Generating new key pair for secure file sharing..."
|
630
|
+
key_pair = Lanet::Signer.generate_key_pair
|
631
|
+
File.write(private_key_path, key_pair[:private_key])
|
632
|
+
File.write(public_key_path, key_pair[:public_key])
|
633
|
+
puts "Keys generated successfully."
|
634
|
+
end
|
635
|
+
|
636
|
+
# Load the private key
|
637
|
+
@private_key = File.read(private_key_path)
|
638
|
+
end
|
639
|
+
|
640
|
+
def share_file(target_ip, file_path)
|
641
|
+
unless File.exist?(file_path)
|
642
|
+
puts "Error: File not found: #{file_path}"
|
643
|
+
return false
|
644
|
+
end
|
645
|
+
|
646
|
+
puts "Sharing file: #{File.basename(file_path)} (#{File.size(file_path)} bytes)"
|
647
|
+
puts "Target: #{target_ip}"
|
648
|
+
puts "Security: Encrypted with team key and digitally signed"
|
649
|
+
|
650
|
+
begin
|
651
|
+
@transfer.send_file(target_ip, file_path, @team_key, @private_key) do |progress, bytes, total|
|
652
|
+
print "\rProgress: #{progress}% (#{bytes}/#{total} bytes)"
|
653
|
+
end
|
654
|
+
puts "\nFile shared successfully!"
|
655
|
+
true
|
656
|
+
rescue StandardError => e
|
657
|
+
puts "\nError sharing file: #{e.message}"
|
658
|
+
false
|
659
|
+
end
|
660
|
+
end
|
661
|
+
|
662
|
+
def start_receiver(output_dir = './shared_files')
|
663
|
+
FileUtils.mkdir_p(output_dir) unless Dir.exist?(output_dir)
|
664
|
+
puts "Listening for incoming files..."
|
665
|
+
puts "Files will be saved to: #{output_dir}"
|
666
|
+
|
667
|
+
@transfer.receive_file(output_dir, @team_key, File.read(public_key_path)) do |event, data|
|
668
|
+
case event
|
669
|
+
when :start
|
670
|
+
puts "\nIncoming file: #{data[:file_name]} from #{data[:sender_ip]}"
|
671
|
+
puts "Size: #{data[:file_size]} bytes"
|
672
|
+
when :progress
|
673
|
+
print "\rReceiving: #{data[:progress]}% complete"
|
674
|
+
when :complete
|
675
|
+
puts "\nFile received: #{data[:file_path]}"
|
676
|
+
puts "Signature verified: Authentic file from team member"
|
677
|
+
when :error
|
678
|
+
puts "\nError: #{data[:error]}"
|
679
|
+
end
|
680
|
+
end
|
681
|
+
end
|
682
|
+
|
683
|
+
private
|
684
|
+
|
685
|
+
def private_key_path
|
686
|
+
File.join(@keys_dir, 'team_private.key')
|
687
|
+
end
|
688
|
+
|
689
|
+
def public_key_path
|
690
|
+
File.join(@keys_dir, 'team_public.key')
|
691
|
+
end
|
692
|
+
end
|
496
693
|
|
497
|
-
|
694
|
+
# Usage:
|
695
|
+
# sharing = SecureTeamFileSharing.new("team-secret-key-123")
|
696
|
+
#
|
697
|
+
# To share a file:
|
698
|
+
# sharing.share_file("192.168.1.5", "important_document.pdf")
|
699
|
+
#
|
700
|
+
# To receive files:
|
701
|
+
# sharing.start_receiver("./team_files")
|
702
|
+
```
|
703
|
+
|
704
|
+
This example:
|
705
|
+
- Creates a secure file sharing system with end-to-end encryption
|
706
|
+
- Uses team-wide encryption key for confidentiality
|
707
|
+
- Implements digital signatures to verify file authenticity
|
708
|
+
- Provides real-time progress tracking for both sending and receiving files
|
709
|
+
- Handles errors gracefully with user-friendly messages
|
498
710
|
|
499
711
|
## Development
|
500
712
|
|