more fixup

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens Langhammer
2025-05-15 02:39:59 +02:00
parent 06e76a5b37
commit fd4bfe604d
2 changed files with 5 additions and 5 deletions

View File

@ -69,7 +69,7 @@ func Decode(raw []byte) (*Packet, error) {
}
func (p *Packet) Encode() ([]byte, error) {
buff := make([]byte, 5)
buff := make([]byte, 4)
buff[0] = uint8(p.code)
buff[1] = uint8(p.id)
@ -77,10 +77,10 @@ func (p *Packet) Encode() ([]byte, error) {
if err != nil {
return buff, err
}
binary.BigEndian.PutUint16(buff[2:], uint16(len(payloadBuffer)+5))
if p.code == CodeRequest || p.code == CodeResponse {
buff[4] = uint8(p.msgType)
buff = append(buff, uint8(p.msgType))
}
buff = append(buff, payloadBuffer...)
binary.BigEndian.PutUint16(buff[2:], uint16(len(buff)))
return buff, nil
}

View File

@ -54,12 +54,12 @@ func (conn *TLSConnection) Read(p []byte) (int, error) {
n, err := conn.reader.Read(p)
if n == 0 {
log.Debugf("TLS(buffer): Attempted read %d from empty buffer, stalling...", len(p))
time.Sleep(500 * time.Millisecond)
time.Sleep(100 * time.Millisecond)
continue
}
if conn.expectedWriterByteCount > 0 && conn.writtenByteCount < int(conn.expectedWriterByteCount) {
log.Debugf("TLS(buffer): Attempted read %d while waiting for bytes %d, stalling...", len(p), conn.expectedWriterByteCount-conn.reader.Len())
time.Sleep(500 * time.Millisecond)
time.Sleep(100 * time.Millisecond)
continue
}
if conn.expectedWriterByteCount > 0 && conn.writtenByteCount == int(conn.expectedWriterByteCount) {