Skip to content

Conversation

@tgrothe
Copy link
Owner

@tgrothe tgrothe commented Dec 16, 2025

Refactor command-line argument parsing

closes #5

This pull request refactors and enhances the argument parsing and execution logic for the port knocking tool in Main.java. The changes introduce a finite state machine (FSM) for argument validation, improve input parsing, and restructure the knocking sequence to use a list of actions. Additionally, output messages are improved for clarity.

Argument parsing and validation improvements:

  • Replaced the previous mode-based parsing with a finite state machine (fsm) using a Symbol enum and a Map to enforce valid argument sequences and transitions. [1] [2] [3]
  • Added helper methods parseDelay and parsePort to validate and parse delay and port arguments, ensuring values are within acceptable ranges.

Knocking sequence execution changes:

  • Changed the knocking sequence to a list of Runnable actions, allowing flexible sequencing of UDP/TCP knocks and delays, and removed the last delay to avoid unnecessary waiting. [1] [2]
  • Added a new knockDelay method to encapsulate delay logic and handle interruptions gracefully.

Output and feedback enhancements:

  • Updated knockUDP and knockTCP methods to print status messages before and after each knock, providing better user feedback. [1] [2]

Refactor command-line argument parsing
@tgrothe tgrothe merged commit 7b646de into main Dec 16, 2025
2 of 3 checks passed
@tgrothe tgrothe deleted the patch-2025-12-16-21-06 branch December 16, 2025 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor command-line argument parsing

2 participants