Since these are single bytes instead of v2 or v3 messages they need
custom tracing logic. These "messages" don't even have official names
in the protocol specification, so I (Jelte) called them SSLResponse and
GSSENCResponse here.
Author: Jelte Fennema-Nio <
[email protected]>
Discussion: https://postgr.es/m/CAGECzQSoPHtZ4xe0raJ6FYSEiPPS+YWXBhOGo+Y1YecLgknF3g@mail.gmail.com
}
if (SSLok == 'S')
{
+ if (conn->Pfdebug)
+ pqTraceOutputCharResponse(conn, "SSLResponse",
+ SSLok);
/* mark byte consumed */
conn->inStart = conn->inCursor;
}
else if (SSLok == 'N')
{
+ if (conn->Pfdebug)
+ pqTraceOutputCharResponse(conn, "SSLResponse",
+ SSLok);
/* mark byte consumed */
conn->inStart = conn->inCursor;
if (gss_ok == 'N')
{
+ if (conn->Pfdebug)
+ pqTraceOutputCharResponse(conn, "GSSENCResponse",
+ gss_ok);
+
/*
* The connection is still valid, so if it's OK to
* continue without GSS, we can proceed using this
gss_ok);
goto error_return;
}
+
+ if (conn->Pfdebug)
+ pqTraceOutputCharResponse(conn, "GSSENCResponse",
+ gss_ok);
}
/* Begin or continue GSSAPI negotiation */
fputc('\n', conn->Pfdebug);
}
+
+/*
+ * Trace a single-byte backend response received for a known request
+ * type the frontend previously sent. Only useful for the simplest of
+ * FE/BE interaction workflows such as SSL/GSS encryption requests.
+ */
+void
+pqTraceOutputCharResponse(PGconn *conn, const char *responseType,
+ char response)
+{
+ if ((conn->traceFlags & PQTRACE_SUPPRESS_TIMESTAMPS) == 0)
+ {
+ char timestr[128];
+
+ pqTraceFormatTimestamp(timestr, sizeof(timestr));
+ fprintf(conn->Pfdebug, "%s\t", timestr);
+ }
+
+ fprintf(conn->Pfdebug, "B\t1\t%s\t %c\n", responseType, response);
+}
extern void pqTraceOutputMessage(PGconn *conn, const char *message,
bool toServer);
extern void pqTraceOutputNoTypeByteMessage(PGconn *conn, const char *message);
+extern void pqTraceOutputCharResponse(PGconn *conn, const char *responseType,
+ char response);
/* === miscellaneous macros === */