Source File
frontend.go
Belonging Package
github.com/jackc/pgproto3/v2
package pgproto3
import (
)
authenticationOk AuthenticationOk
authenticationCleartextPassword AuthenticationCleartextPassword
authenticationMD5Password AuthenticationMD5Password
authenticationSASL AuthenticationSASL
authenticationSASLContinue AuthenticationSASLContinue
authenticationSASLFinal AuthenticationSASLFinal
backendKeyData BackendKeyData
bindComplete BindComplete
closeComplete CloseComplete
commandComplete CommandComplete
copyBothResponse CopyBothResponse
copyData CopyData
copyInResponse CopyInResponse
copyOutResponse CopyOutResponse
copyDone CopyDone
dataRow DataRow
emptyQueryResponse EmptyQueryResponse
errorResponse ErrorResponse
functionCallResponse FunctionCallResponse
noData NoData
noticeResponse NoticeResponse
notificationResponse NotificationResponse
parameterDescription ParameterDescription
parameterStatus ParameterStatus
parseComplete ParseComplete
readyForQuery ReadyForQuery
rowDescription RowDescription
portalSuspended PortalSuspended
bodyLen int
msgType byte
partialMsg bool
}
func ( *Frontend) () (BackendMessage, error) {
if !.partialMsg {
, := .cr.Next(5)
if != nil {
return nil, translateEOFtoErrUnexpectedEOF()
}
.msgType = [0]
.bodyLen = int(binary.BigEndian.Uint32([1:])) - 4
.partialMsg = true
}
, := .cr.Next(.bodyLen)
if != nil {
return nil, translateEOFtoErrUnexpectedEOF()
}
.partialMsg = false
var BackendMessage
switch .msgType {
case '1':
= &.parseComplete
case '2':
= &.bindComplete
case '3':
= &.closeComplete
case 'A':
= &.notificationResponse
case 'c':
= &.copyDone
case 'C':
= &.commandComplete
case 'd':
= &.copyData
case 'D':
= &.dataRow
case 'E':
= &.errorResponse
case 'G':
= &.copyInResponse
case 'H':
= &.copyOutResponse
case 'I':
= &.emptyQueryResponse
case 'K':
= &.backendKeyData
case 'n':
= &.noData
case 'N':
= &.noticeResponse
case 'R':
var error
, = .findAuthenticationMessageType()
if != nil {
return nil,
}
case 's':
= &.portalSuspended
case 'S':
= &.parameterStatus
case 't':
= &.parameterDescription
case 'T':
= &.rowDescription
case 'V':
= &.functionCallResponse
case 'W':
= &.copyBothResponse
case 'Z':
= &.readyForQuery
default:
return nil, fmt.Errorf("unknown message type: %c", .msgType)
}
= .Decode()
return ,
}
const (
AuthTypeOk = 0
AuthTypeCleartextPassword = 3
AuthTypeMD5Password = 5
AuthTypeSASL = 10
AuthTypeSASLContinue = 11
AuthTypeSASLFinal = 12
)
func ( *Frontend) ( []byte) (BackendMessage, error) {
if len() < 4 {
return nil, errors.New("authentication message too short")
}
:= binary.BigEndian.Uint32([:4])
switch {
case AuthTypeOk:
return &.authenticationOk, nil
case AuthTypeCleartextPassword:
return &.authenticationCleartextPassword, nil
case AuthTypeMD5Password:
return &.authenticationMD5Password, nil
case AuthTypeSASL:
return &.authenticationSASL, nil
case AuthTypeSASLContinue:
return &.authenticationSASLContinue, nil
case AuthTypeSASLFinal:
return &.authenticationSASLFinal, nil
default:
return nil, fmt.Errorf("unknown authentication type: %d", )
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |