Class QuicFraming
MessageFramer cuts the streams of an intercepted QUIC connection into messages, for
a QuicInterceptor that overrides QuicInterceptor.streamMessage(org.microproxy.quic.QuicMessage, org.microproxy.quic.QuicStreamContext); the limit on a
message's size; and the error code a stream is reset with when a message is too large or
malformed. Configure it with HttpProxyServerBootstrap.withQuicFraming(org.microproxy.quic.QuicFraming).
Rules map a key to a framer's name. A key is an ALPN protocol (doq), a host name
(dns.example.com, matched against the server's host and the SNI, ignoring case;
*.example.com also matches the names below it), or * for any connection. A host rule
wins over an ALPN rule, which wins over *. The framers' names: u16, u32,
varint, lf and crlf (see MessageFramer), none for no
framing, and names given with withFramer(java.lang.String, org.microproxy.quic.MessageFramer) (a script's framer is script).
QuicFraming framing = QuicFraming.parse("myproto=varint,dns.example.com=u16,*=none") // --quic-framing
.withRule("chat", MessageFramer.lines())
.withMaxMessageSize(64 * 1024); // --quic-max-message-size
defaults() frames DNS over QUIC (doq) with u16, as RFC 9250 says;
every other connection is unframed. Framing applies only to an interceptor that overrides
streamMessage: other interceptors see each read through QuicInterceptor.streamData(org.microproxy.quic.QuicStreamMessage, org.microproxy.quic.QuicStreamContext), and
nothing is kept. Instances are immutable; the with methods return changed copies.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longThe default application error code of the resets for a message that is too large or malformed: 0x2, DOQ_PROTOCOL_ERROR in DNS over QUIC (RFC 9250 section 8.4).static final intThe default limit on a message's size, its prefix or delimiter included: 1 MiB.static final StringThe name of no framing. -
Method Summary
Modifier and TypeMethodDescriptionstatic QuicFramingdefaults()Returns the default framing:doq=u16, with the default limit and error code.longReturns the application error code of the resets for a message that is too large or malformed.The framer for a connection: that of the first host rule matchinghostorsni, else that of thealpnrule, else that of*.framerFor(QuicContext connection) The framer for an intercepted connection, by its ALPN, host and SNI.intReturns the most bytes a message may have, its prefix or delimiter included.static QuicFramingnone()Returns no rules at all: every connection unframed, DNS over QUIC included.static QuicFramingrules()Returns the rules, key to framer name, in lower case and in the order given.toString()voidvalidate()Checks that every rule names a framer there is.withErrorCode(long errorCode) These rules with another error code for the resets of a stream whose message is too large or malformed.withFramer(String name, MessageFramer framer) These rules with a framer that rules can name, replacing one of the same name.withMaxMessageSize(int maxMessageSize) These rules with another limit on a message's size.These rules with one more:keyframed by the framer namedframer.withRule(String key, MessageFramer framer) These rules with one more:keyframed byframer, which is given the namekeyamong the framers.These rules with those ofspecadded; a rule for a key that has one replaces it.
-
Field Details
-
DEFAULT_MAX_MESSAGE_SIZE
public static final int DEFAULT_MAX_MESSAGE_SIZEThe default limit on a message's size, its prefix or delimiter included: 1 MiB.- See Also:
-
DEFAULT_ERROR_CODE
public static final long DEFAULT_ERROR_CODEThe default application error code of the resets for a message that is too large or malformed: 0x2, DOQ_PROTOCOL_ERROR in DNS over QUIC (RFC 9250 section 8.4).- See Also:
-
NONE
The name of no framing.- See Also:
-
-
Method Details
-
defaults
Returns the default framing:doq=u16, with the default limit and error code.- Returns:
- the default framing:
doq=u16, with the default limit and error code
-
none
Returns no rules at all: every connection unframed, DNS over QUIC included.- Returns:
- no rules at all: every connection unframed, DNS over QUIC included
-
parse
- Parameters:
spec- comma-separatedkey=framerrules, such asdoq=u16,myproto=varint,*=none- Returns:
- the framing
- Throws:
IllegalArgumentException- if a rule is notkey=framer
-
withRules
These rules with those ofspecadded; a rule for a key that has one replaces it.- Parameters:
spec- comma-separatedkey=framerrules- Returns:
- the copy
- Throws:
IllegalArgumentException- if a rule is notkey=framer
-
withRule
These rules with one more:keyframed by the framer namedframer.- Parameters:
key- an ALPN protocol, a host name (*.example.comfor the names below it) or*framer- a framer's name, or "none"- Returns:
- the copy
-
withRule
These rules with one more:keyframed byframer, which is given the namekeyamong the framers.- Parameters:
key- an ALPN protocol, a host name or*framer- the framer- Returns:
- the copy
-
withFramer
These rules with a framer that rules can name, replacing one of the same name.- Parameters:
name- the name (not a built-in framer's)framer- the framer- Returns:
- the copy
- Throws:
IllegalArgumentException- ifnameis a built-in framer's or "none"
-
withMaxMessageSize
These rules with another limit on a message's size.- Parameters:
maxMessageSize- the most bytes a message may have, its prefix or delimiter included- Returns:
- the copy
- Throws:
IllegalArgumentException- if the limit is not positive
-
withErrorCode
These rules with another error code for the resets of a stream whose message is too large or malformed.- Parameters:
errorCode- the application error code, below 262- Returns:
- the copy
- Throws:
IllegalArgumentException- if the code is negative or too large for QUIC
-
rules
Returns the rules, key to framer name, in lower case and in the order given.- Returns:
- the rules, key to framer name, in lower case and in the order given
-
maxMessageSize
public int maxMessageSize()Returns the most bytes a message may have, its prefix or delimiter included.- Returns:
- the most bytes a message may have, its prefix or delimiter included
-
errorCode
public long errorCode()Returns the application error code of the resets for a message that is too large or malformed.- Returns:
- the application error code of the resets for a message that is too large or malformed
-
framerFor
The framer for a connection: that of the first host rule matchinghostorsni, else that of thealpnrule, else that of*.- Parameters:
alpn- the negotiated ALPN protocol, or nullhost- the server's host name or address, or nullsni- the SNI, or null- Returns:
- the framer, or null for none
- Throws:
IllegalStateException- if the rule names a framer there is none of
-
framerFor
The framer for an intercepted connection, by its ALPN, host and SNI.- Parameters:
connection- the connection- Returns:
- the framer, or null for none
- Throws:
IllegalStateException- if the rule names a framer there is none of
-
validate
public void validate()Checks that every rule names a framer there is.- Throws:
IllegalArgumentException- naming the first rule that does not
-
toString
-