Skip to content

Add RFC1143 compliant negotiation to prevent telnet loops#83

Open
chodurkhyun wants to merge 1 commit into9swampy:developfrom
chodurkhyun:feature/prevent-negotiation-loop
Open

Add RFC1143 compliant negotiation to prevent telnet loops#83
chodurkhyun wants to merge 1 commit into9swampy:developfrom
chodurkhyun:feature/prevent-negotiation-loop

Conversation

@chodurkhyun
Copy link

Summary


This PR introduces RFC1143 compliant telnet option negotiation support to address potential negotiation loops and improve subnegotiation handling.



Background

As discussed in issue #82 , I encountered telnet negotiation loops in production where clients and servers would get stuck in infinite WILL-SGA <-> DO-SGA cycles. And during the debugging process to resolve these loops, I also discovered that the current subnegotiation implementation couldn't handle sequences like IAC
 SB TERMINAL-TYPE 01 01 IAC SE sent by my target server, causing the client to send WONT instead of properly responding with terminal type information.



Key Improvements

  • Adds RFC1143 compliant negotiation with Q-method state machine to prevent telnet loops
  • Introduces NegotiationMode enum allowing users to choose between Simple (default) and Rfc1143 modes
  • Robust subnegotiation parser correctly handles IAC escaping and variable-length data sequences
  • Cross-handler state persistence via NegotiationStateManager ensures FSM state continuity when ByteStreamHandlers are recreated

  • Maintains full backward compatibility ensuring existing code continues to work unchanged



I'd be happy to address any feedback or questions you might have about this implementation. Thank you for your time reviewing this PR!

…he telnet loop

- Add NegotiationMode enum with Simple and Rfc1143 options
- Implement Rfc1143OptionNegotiator with Q-method state machine
- Add NegotiationStateManager for cross-handler state persistence
- Improve subnegotiation handling with proper variable-length data parsing
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.

1 participant