Skip to content

Conversation

@tgrothe
Copy link
Owner

@tgrothe tgrothe commented Dec 16, 2025

This pull request updates the state transitions in the finite state machine (FSM) logic within Main.java. The changes adjust how the FSM responds to certain symbols, likely to fix or refine its behavior.

FSM transition updates:

  • Changed the transition for Symbol.HOST in state 1 to go to state 3 instead of state 2.
  • Changed the transition for Symbol.DELAY in state 2 to go to state 3 instead of state 1.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes the finite state machine (FSM) logic in the port knocking application to prevent invalid parameter specifications. The changes ensure that the optional delay and host parameters can each be specified at most once (in any order) before port knocking begins, eliminating a previously possible infinite cycle between states 1 and 2.

  • Modified state transitions to prevent multiple specifications of delay and host parameters
  • Both parameter orderings (delay→host and host→delay) now converge to state 3 where only port specifications are allowed
Comments suppressed due to low confidence (1)

src/main/java/Main.java:90

  • The FSM state transition logic lacks test coverage. The changes to the state transitions are not covered by any automated tests, which makes it difficult to verify that the FSM behaves correctly for various input sequences. Consider adding tests that verify:
  • Valid sequences: delay then host, host then delay, delay only, host only, neither
  • Invalid sequences that should be rejected: multiple delay specifications, multiple host specifications
  • Transitions to and behavior in each state
    fsm.put(
        0,
        Map.of(
            Symbol.DELAY, 1,
            Symbol.HOST, 2,
            Symbol.UDP, 3,
            Symbol.TCP, 3));
    fsm.put(
        1,
        Map.of(
            Symbol.HOST, 3,
            Symbol.UDP, 3,
            Symbol.TCP, 3));
    fsm.put(
        2,
        Map.of(
            Symbol.DELAY, 3,
            Symbol.UDP, 3,
            Symbol.TCP, 3));
    fsm.put(
        3,
        Map.of(
            Symbol.UDP, 3,
            Symbol.TCP, 3));

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tgrothe tgrothe merged commit 54c7415 into main Dec 16, 2025
8 of 9 checks passed
@tgrothe tgrothe deleted the patch-2025-12-16-21-44 branch December 16, 2025 20:50
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.

2 participants