fix: stabilize TELNET connection flow and enable LLM prompts#260
fix: stabilize TELNET connection flow and enable LLM prompts#260mariocandela merged 1 commit intobeelzebub-labs:mainfrom
Conversation
📝 WalkthroughWalkthroughThis PR extends TELNET protocol support to LLM integration, exposes the TELNET port in Docker Compose, refines IAC negotiation and input handling in the TELNET implementation, improves error context in the cloud plugin, and adds corresponding test coverage. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@protocols/strategies/TELNET/telnet.go`:
- Around line 328-330: The discarded conn.Read call when handling IAC option
bytes (cases WILL, WONT, DO, DONT) ignores errors and can leave buf[0] stale if
the connection drops; update the code in telnet.go so the read used to discard
the option byte checks both (n, err) = conn.Read(buf[:1]) and handles errors
(return or break from the loop on non-nil err or n==0) instead of ignoring them,
ensuring you don't proceed using an uninitialized buf[0].
🧹 Nitpick comments (2)
protocols/strategies/TELNET/telnet.go (2)
339-342: Consider adding explicit parentheses for readability.The precedence is correct (
&&>||in Go), but explicit grouping makes intent clearer at a glance.Suggested tweak
- if b >= 32 && b <= 126 || b == '\t' { + if (b >= 32 && b <= 126) || b == '\t' {
284-292: Negotiation drain reads only once — may miss multi-segment IAC bursts.
conn.Readreturns as soon as any data is available, so if the client sends negotiation across multiple TCP segments (common with some telnet clients), only the first segment is consumed. Consider a small read loop until the deadline expires.Suggested approach
func negotiateTelnet(conn net.Conn) { buf := make([]byte, 256) conn.SetReadDeadline(time.Now().Add(100 * time.Millisecond)) - conn.Read(buf) + for { + _, err := conn.Read(buf) + if err != nil { + break + } + } conn.SetReadDeadline(time.Time{}) }
|
Issue: #259 |
mariocandela
left a comment
There was a problem hiding this comment.
LGTM, nice work! :)
Describe the bug
TELNET had two issues:
login/terminal could freeze during connection handling
LLMHoneypot commands failed on TELNET with ìno prompt for protocol selected'
To Reproduce
Enable TELNET with a command using plugin: "LLMHoneypot".
Start Beelzebub and connect via telnet.
Log in and run commands like git or uname.
See freeze behavior or LLM failure.
Expected behavior
TELNET login should be stable, and TELNET LLM commands should work like SSH.
Summary by CodeRabbit
New Features
Bug Fixes
Tests