lanet 0.2.0 → 0.3.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 +22 -1
- data/Gemfile.lock +1 -1
- data/README.md +163 -18
- data/index.html +388 -16
- data/lib/lanet/cli.rb +95 -14
- data/lib/lanet/file_transfer.rb +308 -0
- data/lib/lanet/scanner.rb +101 -135
- data/lib/lanet/version.rb +1 -1
- data/lib/lanet.rb +36 -27
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63793d57879f73e9391c3fe104d23d85e6fb67c8eeb2f87c20dcb5aa7166a1d8
|
4
|
+
data.tar.gz: 90157da24d774e9066f2a4ae7c31df2410bec002724e91a3db16e27cae265728
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db2199bbc4023df5e242152283e6ef3fe458dd06df80b931ebf1daebc3607cad6f73bd58cc1ec0f192b08fc0c467f86c92ecc3e19c07c829bbb41066d2d5ad35
|
7
|
+
data.tar.gz: e53ef8a5e71aa920f487c0d8437976c78c8102baf41923b069c414512b1b9930a0804cac9e44023668cf0923c80afc71b6c0c7eb82f6f4cfb7d542676f1842bc
|
data/CHANGELOG.md
CHANGED
@@ -5,7 +5,28 @@ 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.
|
8
|
+
## [0.3.0] - 2025-03-08
|
9
|
+
|
10
|
+
### Added
|
11
|
+
- Encrypted file transfer support over LAN
|
12
|
+
- New `FileTransfer` class for sending and receiving files securely
|
13
|
+
- CLI commands for file transfer operations:
|
14
|
+
- `send-file` - Send a file to a specific target
|
15
|
+
- `receive-file` - Listen for incoming files
|
16
|
+
- Progress tracking for file transfers
|
17
|
+
- File integrity verification via SHA-256 checksums
|
18
|
+
- Support for digital signatures in file transfers
|
19
|
+
- File chunking for efficient transfer of large files
|
20
|
+
- Comprehensive documentation and examples
|
21
|
+
|
22
|
+
## [0.2.1] - 2025-03-07
|
23
|
+
|
24
|
+
### Fixed
|
25
|
+
- Fixed thread handling in Scanner class to properly handle thread termination
|
26
|
+
- Improved test coverage for thread management in scanner specs
|
27
|
+
- Resolved issue with ARP updater thread cleanup
|
28
|
+
|
29
|
+
## [0.2.0] - 2025-03-07
|
9
30
|
|
10
31
|
### Added
|
11
32
|
- Digital signature support for message authentication and integrity
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,23 +1,24 @@
|
|
1
1
|
# Lanet
|
2
2
|
|
3
|
-

|
4
|
-

|
3
|
+
[](https://rubygems.org/gems/lanet)
|
4
|
+
[](https://rubygems.org/gems/lanet)
|
5
5
|
[](https://opensource.org/licenses/MIT)
|
6
6
|
|
7
7
|
A lightweight, powerful LAN communication tool that enables secure message exchange between devices on the same network. Lanet makes peer-to-peer networking simple with built-in encryption, network discovery, and both targeted and broadcast messaging capabilities.
|
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
|
21
22
|
|
22
23
|
## Security Features
|
23
24
|
|
@@ -266,6 +267,40 @@ Ping multiple hosts continuously:
|
|
266
267
|
lanet ping --hosts 192.168.1.5,192.168.1.6 --continuous
|
267
268
|
```
|
268
269
|
|
270
|
+
#### Sending Files Securely
|
271
|
+
|
272
|
+
Send files with encryption:
|
273
|
+
|
274
|
+
```bash
|
275
|
+
lanet send-file --target 192.168.1.5 --file document.pdf --key "my_secret_key"
|
276
|
+
```
|
277
|
+
|
278
|
+
Send files with encryption and digital signatures:
|
279
|
+
|
280
|
+
```bash
|
281
|
+
lanet send-file --target 192.168.1.5 --file document.pdf --key "my_secret_key" --private-key-file lanet_private.key
|
282
|
+
```
|
283
|
+
|
284
|
+
#### Receiving Files
|
285
|
+
|
286
|
+
Listen for incoming files:
|
287
|
+
|
288
|
+
```bash
|
289
|
+
lanet receive-file --output ./downloads
|
290
|
+
```
|
291
|
+
|
292
|
+
Receive encrypted files:
|
293
|
+
|
294
|
+
```bash
|
295
|
+
lanet receive-file --output ./downloads --encryption-key "my_secret_key"
|
296
|
+
```
|
297
|
+
|
298
|
+
Receive encrypted files with signature verification:
|
299
|
+
|
300
|
+
```bash
|
301
|
+
lanet receive-file --output ./downloads --encryption-key "my_secret_key" --public-key-file lanet_public.key
|
302
|
+
```
|
303
|
+
|
269
304
|
### Ruby API
|
270
305
|
|
271
306
|
You can also use Lanet programmatically in your Ruby applications:
|
@@ -340,6 +375,24 @@ end
|
|
340
375
|
|
341
376
|
# Ping multiple hosts continuously
|
342
377
|
pinger.ping_hosts(['192.168.1.5', '192.168.1.6'], true, true)
|
378
|
+
|
379
|
+
# Work with secure file transfers
|
380
|
+
file_transfer = Lanet.file_transfer
|
381
|
+
file_transfer.send_file('192.168.1.5', 'document.pdf', 'encryption_key') do |progress, bytes, total|
|
382
|
+
puts "Progress: #{progress}% (#{bytes}/#{total} bytes)"
|
383
|
+
end
|
384
|
+
|
385
|
+
# Receive files
|
386
|
+
file_transfer.receive_file('./downloads', 'encryption_key') do |event, data|
|
387
|
+
case event
|
388
|
+
when :start
|
389
|
+
puts "Receiving file: #{data[:file_name]} from #{data[:sender_ip]}"
|
390
|
+
when :progress
|
391
|
+
puts "Progress: #{data[:progress]}%"
|
392
|
+
when :complete
|
393
|
+
puts "File saved to: #{data[:file_path]}"
|
394
|
+
end
|
395
|
+
end
|
343
396
|
```
|
344
397
|
|
345
398
|
## Configuration
|
@@ -487,14 +540,106 @@ end
|
|
487
540
|
# monitor.run_continuous_monitoring
|
488
541
|
```
|
489
542
|
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
- Continuously monitors critical devices like servers and network equipment
|
494
|
-
- Alerts administrators when a device's status changes
|
495
|
-
- Can be extended with additional notification methods
|
543
|
+
## Use Case Example: Securely Sharing Files in a Team Environment
|
544
|
+
|
545
|
+
This example demonstrates how to use Lanet's file transfer capabilities to securely share files within a team:
|
496
546
|
|
497
|
-
|
547
|
+
```ruby
|
548
|
+
require 'lanet'
|
549
|
+
require 'fileutils'
|
550
|
+
|
551
|
+
class SecureTeamFileSharing
|
552
|
+
def initialize(team_key, keys_dir = '~/.lanet_keys')
|
553
|
+
@team_key = team_key
|
554
|
+
@keys_dir = File.expand_path(keys_dir)
|
555
|
+
@transfer = Lanet.file_transfer
|
556
|
+
|
557
|
+
# Ensure keys directory exists
|
558
|
+
FileUtils.mkdir_p(@keys_dir) unless Dir.exist?(@keys_dir)
|
559
|
+
|
560
|
+
# Generate keys if they don't exist
|
561
|
+
unless File.exist?(private_key_path) && File.exist?(public_key_path)
|
562
|
+
puts "Generating new key pair for secure file sharing..."
|
563
|
+
key_pair = Lanet::Signer.generate_key_pair
|
564
|
+
File.write(private_key_path, key_pair[:private_key])
|
565
|
+
File.write(public_key_path, key_pair[:public_key])
|
566
|
+
puts "Keys generated successfully."
|
567
|
+
end
|
568
|
+
|
569
|
+
# Load the private key
|
570
|
+
@private_key = File.read(private_key_path)
|
571
|
+
end
|
572
|
+
|
573
|
+
def share_file(target_ip, file_path)
|
574
|
+
unless File.exist?(file_path)
|
575
|
+
puts "Error: File not found: #{file_path}"
|
576
|
+
return false
|
577
|
+
end
|
578
|
+
|
579
|
+
puts "Sharing file: #{File.basename(file_path)} (#{File.size(file_path)} bytes)"
|
580
|
+
puts "Target: #{target_ip}"
|
581
|
+
puts "Security: Encrypted with team key and digitally signed"
|
582
|
+
|
583
|
+
begin
|
584
|
+
@transfer.send_file(target_ip, file_path, @team_key, @private_key) do |progress, bytes, total|
|
585
|
+
print "\rProgress: #{progress}% (#{bytes}/#{total} bytes)"
|
586
|
+
end
|
587
|
+
puts "\nFile shared successfully!"
|
588
|
+
true
|
589
|
+
rescue StandardError => e
|
590
|
+
puts "\nError sharing file: #{e.message}"
|
591
|
+
false
|
592
|
+
end
|
593
|
+
end
|
594
|
+
|
595
|
+
def start_receiver(output_dir = './shared_files')
|
596
|
+
FileUtils.mkdir_p(output_dir) unless Dir.exist?(output_dir)
|
597
|
+
puts "Listening for incoming files..."
|
598
|
+
puts "Files will be saved to: #{output_dir}"
|
599
|
+
|
600
|
+
@transfer.receive_file(output_dir, @team_key, File.read(public_key_path)) do |event, data|
|
601
|
+
case event
|
602
|
+
when :start
|
603
|
+
puts "\nIncoming file: #{data[:file_name]} from #{data[:sender_ip]}"
|
604
|
+
puts "Size: #{data[:file_size]} bytes"
|
605
|
+
when :progress
|
606
|
+
print "\rReceiving: #{data[:progress]}% complete"
|
607
|
+
when :complete
|
608
|
+
puts "\nFile received: #{data[:file_path]}"
|
609
|
+
puts "Signature verified: Authentic file from team member"
|
610
|
+
when :error
|
611
|
+
puts "\nError: #{data[:error]}"
|
612
|
+
end
|
613
|
+
end
|
614
|
+
end
|
615
|
+
|
616
|
+
private
|
617
|
+
|
618
|
+
def private_key_path
|
619
|
+
File.join(@keys_dir, 'team_private.key')
|
620
|
+
end
|
621
|
+
|
622
|
+
def public_key_path
|
623
|
+
File.join(@keys_dir, 'team_public.key')
|
624
|
+
end
|
625
|
+
end
|
626
|
+
|
627
|
+
# Usage:
|
628
|
+
# sharing = SecureTeamFileSharing.new("team-secret-key-123")
|
629
|
+
#
|
630
|
+
# To share a file:
|
631
|
+
# sharing.share_file("192.168.1.5", "important_document.pdf")
|
632
|
+
#
|
633
|
+
# To receive files:
|
634
|
+
# sharing.start_receiver("./team_files")
|
635
|
+
```
|
636
|
+
|
637
|
+
This example:
|
638
|
+
- Creates a secure file sharing system with end-to-end encryption
|
639
|
+
- Uses team-wide encryption key for confidentiality
|
640
|
+
- Implements digital signatures to verify file authenticity
|
641
|
+
- Provides real-time progress tracking for both sending and receiving files
|
642
|
+
- Handles errors gracefully with user-friendly messages
|
498
643
|
|
499
644
|
## Development
|
500
645
|
|