lanet 0.5.1 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0fa5904938004f84fe7b8d599da632140a532925cd0a0c48d5986d44443c0987
4
- data.tar.gz: f039a015dcd75704b7fe80f2a84afbd758505048e78bc86001b9821c1be7a353
3
+ metadata.gz: 72df8bd31304f1648109a036a7035f8cfb40ff478b1a46d8bed0252d306f4bd2
4
+ data.tar.gz: db6c6b0a46129375815d6f60d7374aa074b1439950bb99781ce4ff08a76f77ee
5
5
  SHA512:
6
- metadata.gz: ac7892c9bd9179483ea9ebb796fb567a11f79aab6197b1c49a11d2797167e91c59be5da17e861a3e08069bc4ff745eae8534e8cdcda516739906a8011ab9ffc8
7
- data.tar.gz: ef408dedc43f2461c69d0a00ae207f4bd139e06f171cb5cfd0fd6f40e58d2e0aa1bc59403428587f6982a378418ff241fecb1805254b37ea63d1a39ccc8116e3
6
+ metadata.gz: 3e12a7b08354fd83f239dda0ee40097e8c2b9bee826a4b1935036e91940adbae468d17b3f2a1d002159825edf1fd81a8eb37cec829ec2c9cb4fc334c79842e35
7
+ data.tar.gz: 61c354041de57ef4c017bdfc9ad2b6aac5f1162ef8e81e55c928aea89f99700d5638dc8761b0609ab6ca908c0877eeb2842876e4869634f70a60cea5c2ae77b6
data/CHANGELOG.md CHANGED
@@ -5,6 +5,57 @@ 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
+ ## [1.0.0] - 2025-10-19
9
+
10
+ ### 🎉 Major Release - Architectural Improvements
11
+
12
+ This is a major milestone release focused on code quality, maintainability, and architectural improvements while maintaining 100% backward compatibility.
13
+
14
+ ### Added
15
+ - **Configuration Management**: New centralized `Config` class for managing all application constants and settings
16
+ - **Transfer State Management**: New `TransferState` class for better file transfer state handling
17
+ - **Enhanced Error Handling**: Custom exception classes (`SendError`, `ReceiveError`) with detailed context
18
+ - **Resource Management**: Proper cleanup methods (`close`, `closed?`) for network resources
19
+ - **Logging Infrastructure**: Centralized logger configuration via `Config.logger`
20
+ - **Health Monitoring**: Added `healthy?` and `stats` methods to Mesh network for monitoring
21
+ - **Documentation**: Comprehensive refactoring reports (`REFACTORING_REPORT.md`, `REFACTORING_SUMMARY.md`)
22
+
23
+ ### Changed
24
+ - **Encryptor Refactoring**: Split monolithic methods into focused, single-purpose methods
25
+ - Reduced cyclomatic complexity from 12+ to 2-3 per method
26
+ - Extracted `prepare_plaintext`, `prepare_encrypted`, `prepare_signed_plaintext`, `prepare_signed_encrypted`
27
+ - Improved message type parsing with `MessageType` enumeration
28
+ - **Sender Class**: Enhanced with input validation, error handling, and lifecycle management
29
+ - **Receiver Class**: Added graceful shutdown, configurable buffer sizes, and proper cleanup
30
+ - **FileTransfer**: Refactored using `TransferState` for cleaner state management
31
+ - Reduced complexity by extracting state logic
32
+ - Improved progress tracking and checksum verification
33
+ - **Code Organization**: Better separation of concerns across all modules
34
+ - **Constants Management**: Migrated all constants to centralized `Config` class
35
+
36
+ ### Improved
37
+ - **Code Quality Metrics**:
38
+ - 60% reduction in average method length (from 20-30 lines to 5-10 lines)
39
+ - 75% reduction in cyclomatic complexity (critical components)
40
+ - Better error messages with context-specific exceptions
41
+ - **Resource Management**: Eliminated resource leak risks with ensure blocks
42
+ - **Test Coverage**: All 96 tests passing with maintained backward compatibility
43
+ - **Memory Management**: Automatic cleanup of temporary files and network resources
44
+ - **Error Recovery**: More robust failure handling throughout the codebase
45
+
46
+ ### Fixed
47
+ - Resource leaks in socket handling (proper cleanup in all scenarios)
48
+ - Potential memory issues in file transfer (proper temp file cleanup)
49
+ - Port conflict detection and reporting (clearer error messages)
50
+
51
+ ### Technical Details
52
+ For detailed information about the architectural improvements and refactoring:
53
+ - See `REFACTORING_REPORT.md` for comprehensive analysis with metrics
54
+ - See `REFACTORING_SUMMARY.md` for technical implementation details
55
+
56
+ ### Backward Compatibility
57
+ ✅ **100% Backward Compatible** - All public APIs remain unchanged. No migration needed.
58
+
8
59
  ## [0.5.1] - 2025-03-20
9
60
 
10
61
  ### Changed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lanet (0.5.1)
4
+ lanet (1.0.0)
5
5
  thor (~> 1.2)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -369,6 +369,8 @@ lanet traceroute --host github.com --protocol tcp --max-hops 20 --timeout 2 --qu
369
369
 
370
370
  You can also use Lanet programmatically in your Ruby applications:
371
371
 
372
+ #### Basic Usage
373
+
372
374
  ```ruby
373
375
  require 'lanet'
374
376
 
@@ -377,6 +379,22 @@ scanner = Lanet.scanner
377
379
  active_ips = scanner.scan('192.168.1.0/24')
378
380
  puts "Found devices: #{active_ips.join(', ')}"
379
381
 
382
+ # Send a message to a specific IP
383
+ sender = Lanet.sender
384
+ sender.send_to('192.168.1.5', 'Hello from Ruby!')
385
+ sender.close # Proper cleanup (new in v1.0.0)
386
+
387
+ # Listen for incoming messages
388
+ receiver = Lanet.receiver
389
+ receiver.listen do |data, ip|
390
+ puts "Received from #{ip}: #{data}"
391
+ end
392
+ receiver.close # Proper cleanup (new in v1.0.0)
393
+ ```
394
+
395
+ #### Advanced Features
396
+
397
+ ```ruby
380
398
  # Scan with verbose option for detailed output
381
399
  detailed_hosts = scanner.scan('192.168.1.0/24', 1, 32, true)
382
400
  detailed_hosts.each do |host|
@@ -387,23 +405,19 @@ end
387
405
  # Customize scanning performance with timeout and thread count
388
406
  active_ips = scanner.scan('192.168.1.0/24', 0.5, 16) # 0.5 second timeout, 16 threads
389
407
 
390
- # Send a message to a specific IP
391
- sender = Lanet.sender
392
- sender.send_to('192.168.1.5', 'Hello from Ruby!')
393
-
394
408
  # Broadcast a message to all devices
409
+ sender = Lanet.sender
395
410
  sender.broadcast('Announcement to all devices!')
396
-
397
- # Listen for incoming messages
398
- receiver = Lanet.receiver
399
- receiver.listen do |data, ip|
400
- puts "Received from #{ip}: #{data}"
401
- end
411
+ sender.close
402
412
 
403
413
  # Work with encrypted messages
404
414
  encrypted = Lanet.encrypt('Secret message', 'my_encryption_key')
405
415
  decrypted = Lanet.decrypt(encrypted, 'my_encryption_key')
416
+ ```
417
+
418
+ #### Network Monitoring
406
419
 
420
+ ```ruby
407
421
  # Ping a specific host
408
422
  pinger = Lanet.pinger
409
423
  result = pinger.ping_host('192.168.1.5')
@@ -418,11 +432,6 @@ result = pinger.ping_host('192.168.1.5', true) # true enables real-time output
418
432
  pinger = Lanet.pinger
419
433
  pinger.ping_host('192.168.1.5', true, true) # true, true enables real-time continuous output
420
434
 
421
- # Ping without real-time output (for programmatic use)
422
- result = pinger.ping_host('192.168.1.5')
423
- puts "Host reachable: #{result[:status]}"
424
- puts "Response time: #{result[:response_time]}ms"
425
-
426
435
  # Check if a host is reachable
427
436
  if pinger.reachable?('192.168.1.5')
428
437
  puts "Host is up!"
@@ -439,14 +448,20 @@ end
439
448
 
440
449
  # Ping multiple hosts continuously
441
450
  pinger.ping_hosts(['192.168.1.5', '192.168.1.6'], true, true)
451
+ ```
452
+
453
+ #### Secure File Transfers
442
454
 
443
- # Work with secure file transfers
455
+ ```ruby
456
+ # Work with secure file transfers (improved in v1.0.0)
444
457
  file_transfer = Lanet.file_transfer
458
+
459
+ # Send file with progress tracking
445
460
  file_transfer.send_file('192.168.1.5', 'document.pdf', 'encryption_key') do |progress, bytes, total|
446
461
  puts "Progress: #{progress}% (#{bytes}/#{total} bytes)"
447
462
  end
448
463
 
449
- # Receive files
464
+ # Receive files with event handling
450
465
  file_transfer.receive_file('./downloads', 'encryption_key') do |event, data|
451
466
  case event
452
467
  when :start
@@ -455,9 +470,15 @@ file_transfer.receive_file('./downloads', 'encryption_key') do |event, data|
455
470
  puts "Progress: #{data[:progress]}%"
456
471
  when :complete
457
472
  puts "File saved to: #{data[:file_path]}"
473
+ when :error
474
+ puts "Error: #{data[:error]}"
458
475
  end
459
476
  end
477
+ ```
460
478
 
479
+ #### Mesh Networking
480
+
481
+ ```ruby
461
482
  # Mesh Networking
462
483
  mesh = Lanet.mesh_network
463
484
  mesh.start # Start the mesh node and discovery service
@@ -472,9 +493,19 @@ mesh.connections.each do |node_id, info|
472
493
  puts " #{node_id} (#{info[:ip]})"
473
494
  end
474
495
 
496
+ # Check mesh health (new in v1.0.0)
497
+ if mesh.healthy?
498
+ stats = mesh.stats
499
+ puts "Mesh is healthy: #{stats[:connections]} connections, #{stats[:processed_messages]} messages processed"
500
+ end
501
+
475
502
  # Properly stop the mesh node
476
503
  mesh.stop
504
+ ```
477
505
 
506
+ #### Network Path Analysis
507
+
508
+ ```ruby
478
509
  # Trace route to a host with different protocols
479
510
  tracer = Lanet.traceroute(protocol: :udp)
480
511
  hops = tracer.trace('github.com')
@@ -487,6 +518,28 @@ tcp_tracer = Lanet.traceroute(protocol: :tcp, max_hops: 15, timeout: 2)
487
518
  tcp_tracer.trace('google.com')
488
519
  ```
489
520
 
521
+ #### Configuration (New in v1.0.0)
522
+
523
+ ```ruby
524
+ # Access centralized configuration
525
+ require 'lanet'
526
+
527
+ # View default settings
528
+ puts "Default port: #{Lanet::Config::DEFAULT_PORT}"
529
+ puts "File transfer port: #{Lanet::Config::FILE_TRANSFER_PORT}"
530
+ puts "Mesh port: #{Lanet::Config::MESH_PORT}"
531
+ puts "Chunk size: #{Lanet::Config::CHUNK_SIZE}"
532
+
533
+ # Configure custom logger
534
+ Lanet::Config.configure do |config|
535
+ config.logger = Logger.new('lanet.log')
536
+ config.logger.level = Logger::DEBUG
537
+ end
538
+
539
+ # Use the configured logger
540
+ Lanet::Config.logger.info("Starting Lanet application")
541
+ ```
542
+
490
543
  ## Mesh Network
491
544
 
492
545
  The mesh networking feature provides decentralized communication capabilities: