Class ScriptQuicMessage

java.lang.Object
org.microproxy.starlark.ScriptQuicMessage
All Implemented Interfaces:
org.microproxy.thirdparty.starlark.eval.StarlarkValue, org.microproxy.thirdparty.starlark.eval.Structure

public final class ScriptQuicMessage extends Object implements org.microproxy.thirdparty.starlark.eval.Structure
Bytes of an intercepted QUIC connection, as on_quic_stream_data (bytes read from one side of a stream), on_quic_message (one whole message of a framed stream, without its length prefix or delimiter) and on_quic_datagram (one datagram) see them: data, text (None when the bytes are not valid UTF-8, as a character split between two reads is not), from_client, stream_id (on the client's connection; None for a datagram) and timestamp (seconds since the epoch). Assign data or text to change what is passed on, or make a changed copy with with_data, with_text and with_from_client and return it. Without framing, a stream has no message boundaries, as TCP has none: a message is whatever one read returned.
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.microproxy.thirdparty.starlark.syntax.TypeConstructor
    Types the builtins that return this class (see ScriptType).
    Returns the error message to print for an attempt to access an undefined field.
    com.google.common.collect.ImmutableList<String>
    Returns the names of this value's fields, in some undefined but stable order.
    org.microproxy.thirdparty.starlark.syntax.StarlarkType
    getStarlarkType(org.microproxy.thirdparty.starlark.eval.StarlarkSemantics semantics)
    Returns the Starlark type of this struct.
    Returns the value of the field with the given name, or null if the field does not exist.
    void
    repr(org.microproxy.thirdparty.starlark.eval.Printer printer, org.microproxy.thirdparty.starlark.eval.StarlarkSemantics semantics)
    Prints an official representation of object x.
    void
    setField(String field, Object value)
    Updates the named field of this value as if by the Starlark statement this.field = value.
    A copy of this message with other bytes.
    withFromClient(Boolean fromClient)
    A copy of this message going the other way, or the same: on_quic_message returns one with from_client=False to answer the client itself, on the same stream.
    A copy of this message with the UTF-8 encoding of text.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.microproxy.thirdparty.starlark.eval.StarlarkValue

    checkHashable, debugPrint, isAcyclic, isImmutable, str, truth

    Methods inherited from interface org.microproxy.thirdparty.starlark.eval.Structure

    getValue
  • Method Details

    • getAssociatedTypeConstructor

      public static org.microproxy.thirdparty.starlark.syntax.TypeConstructor getAssociatedTypeConstructor()
      Types the builtins that return this class (see ScriptType).
      Returns:
      the Starlark type constructor for a QUIC message value
    • getStarlarkType

      public org.microproxy.thirdparty.starlark.syntax.StarlarkType getStarlarkType(org.microproxy.thirdparty.starlark.eval.StarlarkSemantics semantics)
      Description copied from interface: org.microproxy.thirdparty.starlark.eval.Structure
      Returns the Starlark type of this struct. For efficiency, implementations should override this method to return a memoized value.
      Specified by:
      getStarlarkType in interface org.microproxy.thirdparty.starlark.eval.StarlarkValue
      Specified by:
      getStarlarkType in interface org.microproxy.thirdparty.starlark.eval.Structure
      Parameters:
      semantics - the interpreter settings used to determine the type
      Returns:
      the type of this value, or null when no type information is provided
    • getValue

      public Object getValue(String name)
      Description copied from interface: org.microproxy.thirdparty.starlark.eval.Structure
      Returns the value of the field with the given name, or null if the field does not exist. The interpreter (Starlark code) calls the getValue below, which has access to StarlarkSemantics.

      The set of names for which getValue returns non-null should match getFieldNames if possible.

      Specified by:
      getValue in interface org.microproxy.thirdparty.starlark.eval.Structure
      Parameters:
      name - the name of the field to retrieve
      Returns:
      the field value, or null if the field does not exist
    • getFieldNames

      public com.google.common.collect.ImmutableList<String> getFieldNames()
      Description copied from interface: org.microproxy.thirdparty.starlark.eval.Structure
      Returns the names of this value's fields, in some undefined but stable order.

      A call to getValue for each of these names should return non-null, though this is not enforced.

      The Starlark expression dir(x) reports the union of getFieldNames() and any StarlarkMethod-annotated fields and methods of this value.

      Specified by:
      getFieldNames in interface org.microproxy.thirdparty.starlark.eval.Structure
      Returns:
      the field names in a stable order
    • setField

      public void setField(String field, Object value) throws org.microproxy.thirdparty.starlark.eval.EvalException
      Description copied from interface: org.microproxy.thirdparty.starlark.eval.Structure
      Updates the named field of this value as if by the Starlark statement this.field = value.
      Specified by:
      setField in interface org.microproxy.thirdparty.starlark.eval.Structure
      Parameters:
      field - the name of the field to update
      value - the new Starlark value for the field
      Throws:
      org.microproxy.thirdparty.starlark.eval.EvalException - if the update failed because this value is immutable, does not support field update, or update of that particular field, or because the value was inappropriate.
    • withData

      public ScriptQuicMessage withData(Object data) throws org.microproxy.thirdparty.starlark.eval.EvalException
      A copy of this message with other bytes.
      Parameters:
      data - the bytes of the copy, as bytes or a string (UTF-8)
      Returns:
      the copy, with the same direction and timestamp
      Throws:
      org.microproxy.thirdparty.starlark.eval.EvalException - if data is neither bytes nor a string
    • withText

      public ScriptQuicMessage withText(String text)
      A copy of this message with the UTF-8 encoding of text.
      Parameters:
      text - the text of the copy
      Returns:
      the copy, with the same direction and timestamp
    • withFromClient

      public ScriptQuicMessage withFromClient(Boolean fromClient)
      A copy of this message going the other way, or the same: on_quic_message returns one with from_client=False to answer the client itself, on the same stream.
      Parameters:
      fromClient - whether the copy goes to the server
      Returns:
      the copy, with the same bytes, stream and timestamp
    • getErrorMessageForUnknownField

      public String getErrorMessageForUnknownField(String field)
      Description copied from interface: org.microproxy.thirdparty.starlark.eval.Structure
      Returns the error message to print for an attempt to access an undefined field.

      May return null to use a default error message.

      Specified by:
      getErrorMessageForUnknownField in interface org.microproxy.thirdparty.starlark.eval.Structure
      Parameters:
      field - the undefined field name
      Returns:
      the diagnostic message, or null to use the default
    • repr

      public void repr(org.microproxy.thirdparty.starlark.eval.Printer printer, org.microproxy.thirdparty.starlark.eval.StarlarkSemantics semantics)
      Description copied from interface: org.microproxy.thirdparty.starlark.eval.StarlarkValue
      Prints an official representation of object x.

      Convention is that the string should be parseable back to the value x. If this isn't feasible then it should be a short human-readable description enclosed in angled brackets, e.g. "<foo object>".

      Specified by:
      repr in interface org.microproxy.thirdparty.starlark.eval.StarlarkValue
      Parameters:
      printer - a printer to be used for formatting nested values.
      semantics - the interpreter settings used to format nested values