...
1 package pgproto3
2
3 import (
4 "encoding/binary"
5 "encoding/json"
6 "errors"
7
8 "github.com/jackc/pgx/v5/internal/pgio"
9 )
10
11 const gssEncReqNumber = 80877104
12
13 type GSSEncRequest struct {
14 }
15
16
17 func (*GSSEncRequest) Frontend() {}
18
19 func (dst *GSSEncRequest) Decode(src []byte) error {
20 if len(src) < 4 {
21 return errors.New("gss encoding request too short")
22 }
23
24 requestCode := binary.BigEndian.Uint32(src)
25
26 if requestCode != gssEncReqNumber {
27 return errors.New("bad gss encoding request code")
28 }
29
30 return nil
31 }
32
33
34 func (src *GSSEncRequest) Encode(dst []byte) ([]byte, error) {
35 dst = pgio.AppendInt32(dst, 8)
36 dst = pgio.AppendInt32(dst, gssEncReqNumber)
37 return dst, nil
38 }
39
40
41 func (src GSSEncRequest) MarshalJSON() ([]byte, error) {
42 return json.Marshal(struct {
43 Type string
44 ProtocolVersion uint32
45 Parameters map[string]string
46 }{
47 Type: "GSSEncRequest",
48 })
49 }
50
View as plain text