Subj : armhf installed web telnet garbles input
To   : W5jsn
From : Ree
Date : Thu Sep 05 2024 11:18 am

> The debug .js file, services.ini changes, port forwarding for the debug ports
> are all set up. Have at it!!

Just tried again and was able to connect, and the extra debug information
definitely helped narrow things down, although it's a mystery to me as to why
it's not working.  I've added a bit more debug output to this version, if you
could replace your websocketservice-debug.js with it:
https://tinyurl.com/bdfr3enr

If you're a programmer (or other programmers are reading), here's the relevant
debug output:

> FWebSocketState=WEBSOCKET_NEED_PACKET_START, FFrameOpCode=2

This tells me the incoming packet is a binary frame (2 = binary)

> FWebSocketState=WEBSOCKET_NEED_PAYLOAD_LENGTH, InByte=129, FFrameMasked =
> true, FFramePayloadLength = 1

This tells me the incoming frame is 1 byte long, and is masked.

> FWebSocketState=WEBSOCKET_NEED_MASKING_KEY, InByte=2301443968, FFrameMask =
> 137 45 63 128

This gives us our four masking bytes

> FWebSocketState=WEBSOCKET_DATA, InStr=232

This is the raw data.  Since the frame is masked, you need to xor each incoming
byte with a masking byte.  In this case you'd do 232 XOR 137

> tempBytes = 232

This is the unmasked bytes, which should be the result of the 232 XOR 137
operation, which should be 97, which would correspond with the "a" that I
pressed.  But it's not, it's still the original value of 232, which means
either the XOR operation didn't run, or it ran as 232 XOR 0 for some reason.
The extra debug information will hopefully shed light on what's happening here.

The part that's really confusing me is that the line of code that unmasks the
bytes hasn't changed between the commit that works for you and the commit that
breaks:

> if (FFrameMasked) InByte ^= FFrameMask[FFramePayloadReceived++ % 4];

We know from the debug output above that FFramemasked is true, so the XOR
should be happening.  And while we don't know what the value of
FFramePayloadReceived is (it should be 0, but it's not included in the current
debug output), the % 4 means no matter what value it is we'll always be looking
at elements 0, 1, 2, or 3 in the FFrameMask array, and we know those elements
have values 137, 45, 63, and 128 from the debug output, so it doesn't make
sense that a XOR 0 is happening...

---
■ Synchronet ■ fTelnet Demo Server - ftelnet.synchro.net