Skip to content

Commit f85095a

Browse files
Fix for buggy clients
1 parent 61becf6 commit f85095a

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

proxy/protocol/request_v1.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ func (r *Request) decode(pd packetDecoder) (err error) {
4242
if version, err = pd.getInt16(); err != nil {
4343
return err
4444
}
45+
if version == -1 {
46+
version = r.Body.version()
47+
}
4548
if r.Body.key() != key || r.Body.version() != version {
4649
return PacketDecodingError{fmt.Sprintf("expected request key,version %d,%d but got %d,%d", r.Body.key(), r.Body.version(), key, version)}
4750
}

proxy/protocol/request_v2.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ func (r *RequestV2) decode(pd packetDecoder) (err error) {
4242
if version, err = pd.getInt16(); err != nil {
4343
return err
4444
}
45+
if version == -1 {
46+
version = r.Body.version()
47+
}
4548
if r.Body.key() != key || r.Body.version() != version {
4649
return PacketDecodingError{fmt.Sprintf("expected request key,version %d,%d but got %d,%d", r.Body.key(), r.Body.version(), key, version)}
4750
}

proxy/protocol/responses.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ func modifyApiVersionsResponse(decodedStruct *Struct, fn config.NetAddressMappin
401401

402402
values := []any{int16(17), int16(0), int16(1)}
403403

404+
// version 3+ of the api versions response
404405
if len(schema.GetFields()) > 3 {
405406
values = append(values, []rawTaggedField{})
406407
}

proxy/sasl_local.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import (
44
"bytes"
55
"encoding/binary"
66
"fmt"
7+
"io"
8+
"time"
9+
710
"github.com/grepplabs/kafka-proxy/pkg/apis"
811
"github.com/grepplabs/kafka-proxy/proxy/protocol"
912
"github.com/pkg/errors"
10-
"io"
11-
"time"
1213
)
1314

1415
type LocalSasl struct {
@@ -146,6 +147,10 @@ func (p *LocalSasl) receiveAndSendAuthV1(conn DeadlineReaderWriter, localSaslAut
146147
return errors.Errorf("SaslAuthenticate is expected, but got apiKey %d", requestKeyVersion.ApiKey)
147148
}
148149

150+
if requestKeyVersion.ApiVersion == -1 {
151+
requestKeyVersion.ApiVersion = 1
152+
}
153+
149154
if requestKeyVersion.Length > protocol.MaxRequestSize {
150155
return protocol.PacketDecodingError{Info: fmt.Sprintf("sasl authenticate message of length %d too large", requestKeyVersion.Length)}
151156
}

0 commit comments

Comments
 (0)