Package org.microproxy
Class FlowRecord
java.lang.Object
org.microproxy.FlowRecord
What an access log needs to know about one finished exchange or flow, handed to
ActivityTracker.flowEnded(org.microproxy.FlowRecord) once it is over: an HTTP exchange once its response has been written
(or it was abandoned), a CONNECT tunnel, a SOCKS client's tunnel, a WebSocket session, a
tunnel seen by the TCP hooks, a CONNECT-UDP flow, and a QUIC flow the transparent QUIC listener
relayed or intercepted stream by stream, each when it closes.
Records are immutable, except for the unique id, which is made the
first time it is asked for. Values the proxy does not know are null, or -1 for
numbers.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilds aFlowRecord; unset values are unknown.static enumWhat kind of exchange or flow a record is about;%MP_FLOW%renders itsFlowRecord.Kind.label(). -
Method Summary
Modifier and TypeMethodDescriptionstatic FlowRecord.Builderbuilder(FlowContext context, FlowRecord.Kind kind) Starts a record of an exchange or flow oncontext.longBytes received from the client: the request body for HTTP, the client's payload for a tunnel or a flow.longBytes sent to the client: the response body for HTTP, the server's payload for a tunnel or a flow.context()Returns the client's context of the exchange or flow.Returns the proxy's local address on the client connection, ornull.duration()How long the exchange or flow lasted: for HTTP, from the first byte of the request to the last byte of the response (or until it was abandoned); for a tunnel or a flow, until it closed.longReturns the duration in nanoseconds, or -1 when unknown.failure()Returns why the proxy had to answer itself (seeFlowContext.failure()), or empty.kind()Returns what kind of exchange or flow this is.request()The request as the client sent it, before the proxy and filters rewrote it; for a tunnel or a flow, theCONNECT(real, or made up for a SOCKS client, a transparent connection or a QUIC flow) that opened it.response()Returns the response head the client got (or that a SOCKS or transparent client's tunnel was answered with), ornull.intReturns the status of the response the client got, or 0 when it got none.Returns the response code details (seeFlowContext.responseCodeDetails()), ornull.Returns the response flags (seeFlowContext.responseFlags()), unmodifiable.source()Returns where the response came from, ornullwhen there was none.longReturns when the exchange or flow started (wall clock, epoch milliseconds); 0 when unknown.timings()Returns the exchange's phase timings (seeFlowContext.timings()).toString()trace()The exchange's distributed trace (FlowTracer), whose ids access logs show as%TRACE_ID%and%SPAN_ID%;FlowTrace.NONEwhen nothing traced it.trailers()Returns the response's trailers, ornullwhen it had none.uniqueId()An id unique to this exchange or flow: its trace's request id (X-Request-Id) when it has one, else a random UUID made the first time it is asked for.Returns the address the proxy was connected to for the exchange: the server, or a chained proxy; ornull.longReturns the bytes read from the server connection, heads and framing included, or -1 when unknown.longReturns the bytes written to the server connection, heads and framing included, or -1 when unknown.The name of where the exchange went: the chained proxy it went through (host:port), or else the server'shost:port.Returns the proxy's local address on its connection to the server, ornull.The protocol the proxy spoke toupstreamCluster(): to the chained proxy the exchange went through,HTTP/1.1orHTTP/2(for a tunnel, the protocol itsCONNECTwent in),SOCKS4orSOCKS5; else to the server,HTTP/1.1,HTTP/2orHTTP/3.Returns the TLS session with the server (or a TLS chained proxy), ornull.Returns why the TLS handshake with the server failed, ornull.
-
Method Details
-
builder
Starts a record of an exchange or flow oncontext.- Parameters:
context- the client's context of the exchange or flowkind- what kind of exchange or flow it is- Returns:
- a builder
-
context
Returns the client's context of the exchange or flow.- Returns:
- the client's context of the exchange or flow
-
kind
Returns what kind of exchange or flow this is.- Returns:
- what kind of exchange or flow this is
-
request
The request as the client sent it, before the proxy and filters rewrote it; for a tunnel or a flow, theCONNECT(real, or made up for a SOCKS client, a transparent connection or a QUIC flow) that opened it. Null when the request could not be read.- Returns:
- the client's request head, or
null
-
response
Returns the response head the client got (or that a SOCKS or transparent client's tunnel was answered with), ornull.- Returns:
- the response head the client got (or that a SOCKS or transparent client's tunnel was answered with), or
null
-
trailers
Returns the response's trailers, ornullwhen it had none.- Returns:
- the response's trailers, or
nullwhen it had none
-
source
Returns where the response came from, ornullwhen there was none.- Returns:
- where the response came from, or
nullwhen there was none
-
responseCode
public int responseCode()Returns the status of the response the client got, or 0 when it got none.- Returns:
- the status of the response the client got, or 0 when it got none
-
startEpochMillis
public long startEpochMillis()Returns when the exchange or flow started (wall clock, epoch milliseconds); 0 when unknown.- Returns:
- when the exchange or flow started (wall clock, epoch milliseconds); 0 when unknown
-
duration
How long the exchange or flow lasted: for HTTP, from the first byte of the request to the last byte of the response (or until it was abandoned); for a tunnel or a flow, until it closed.- Returns:
- the duration, or empty when unknown
-
durationNanos
public long durationNanos()Returns the duration in nanoseconds, or -1 when unknown.- Returns:
- the duration in nanoseconds, or -1 when unknown
-
timings
Returns the exchange's phase timings (seeFlowContext.timings()).- Returns:
- the exchange's phase timings (see
FlowContext.timings())
-
bytesReceived
public long bytesReceived()Bytes received from the client: the request body for HTTP, the client's payload for a tunnel or a flow.- Returns:
- the byte count, or -1 when unknown
-
bytesSent
public long bytesSent()Bytes sent to the client: the response body for HTTP, the server's payload for a tunnel or a flow.- Returns:
- the byte count, or -1 when unknown
-
upstreamBytesSent
public long upstreamBytesSent()Returns the bytes written to the server connection, heads and framing included, or -1 when unknown.- Returns:
- the bytes written to the server connection, heads and framing included, or -1 when unknown
-
upstreamBytesReceived
public long upstreamBytesReceived()Returns the bytes read from the server connection, heads and framing included, or -1 when unknown.- Returns:
- the bytes read from the server connection, heads and framing included, or -1 when unknown
-
upstreamAddress
Returns the address the proxy was connected to for the exchange: the server, or a chained proxy; ornull.- Returns:
- the address the proxy was connected to for the exchange: the server, or a chained proxy; or
null
-
upstreamLocalAddress
Returns the proxy's local address on its connection to the server, ornull.- Returns:
- the proxy's local address on its connection to the server, or
null
-
downstreamLocalAddress
Returns the proxy's local address on the client connection, ornull.- Returns:
- the proxy's local address on the client connection, or
null
-
upstreamCluster
The name of where the exchange went: the chained proxy it went through (host:port), or else the server'shost:port.- Returns:
- the upstream's name, or
null
-
upstreamProtocol
The protocol the proxy spoke toupstreamCluster(): to the chained proxy the exchange went through,HTTP/1.1orHTTP/2(for a tunnel, the protocol itsCONNECTwent in),SOCKS4orSOCKS5; else to the server,HTTP/1.1,HTTP/2orHTTP/3.- Returns:
- the protocol, or
nullwhen the exchange reached no upstream, or was a tunnel straight to the server
-
upstreamSslSession
Returns the TLS session with the server (or a TLS chained proxy), ornull.- Returns:
- the TLS session with the server (or a TLS chained proxy), or
null
-
upstreamTransportFailureReason
Returns why the TLS handshake with the server failed, ornull.- Returns:
- why the TLS handshake with the server failed, or
null
-
responseFlags
Returns the response flags (seeFlowContext.responseFlags()), unmodifiable.- Returns:
- the response flags (see
FlowContext.responseFlags()), unmodifiable
-
failure
Returns why the proxy had to answer itself (seeFlowContext.failure()), or empty.- Returns:
- why the proxy had to answer itself (see
FlowContext.failure()), or empty
-
responseCodeDetails
Returns the response code details (seeFlowContext.responseCodeDetails()), ornull.- Returns:
- the response code details (see
FlowContext.responseCodeDetails()), ornull
-
trace
The exchange's distributed trace (FlowTracer), whose ids access logs show as%TRACE_ID%and%SPAN_ID%;FlowTrace.NONEwhen nothing traced it.- Returns:
- the trace
-
uniqueId
An id unique to this exchange or flow: its trace's request id (X-Request-Id) when it has one, else a random UUID made the first time it is asked for.- Returns:
- the unique id
-
toString
-