Record Class HaProxyContext

java.lang.Object
java.lang.Record
io.kroxylicious.proxy.internal.net.HaProxyContext
Record Components:
sourceAddress - the original client address reported by the load-balancer
destinationAddress - the destination address the client connected to
sourcePort - the original client port
destinationPort - the destination port
tlvs - HaProxy v2 TLV extensions keyed by type name, values are byte[]

public record HaProxyContext(String sourceAddress, String destinationAddress, int sourcePort, int destinationPort, Map<String,byte[]> tlvs) extends Record
Immutable snapshot of a decoded PROXY protocol header.

Captures the source/destination addresses, ports and any TLV extensions from the Netty HAProxyMessage so that the reference-counted message can be released immediately after extraction.

  • Constructor Details

    • HaProxyContext

      public HaProxyContext(String sourceAddress, String destinationAddress, int sourcePort, int destinationPort, Map<String,byte[]> tlvs)
      Compact constructor that deep-copies and wraps the TLV map to ensure immutability.
  • Method Details

    • tlvs

      public Map<String,byte[]> tlvs()
      Returns a defensive copy of the TLV map to prevent mutation of internal state.
      Returns:
      a new map with cloned byte array values
    • from

      public static HaProxyContext from(io.netty.handler.codec.haproxy.HAProxyMessage msg)
      Creates an HaProxyContext from a Netty HAProxyMessage.

      TLV content is deep-copied so the returned context is safe to use after the message is released.

      Parameters:
      msg - the decoded proxy message
      Returns:
      an immutable context snapshot
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • sourceAddress

      public String sourceAddress()
      Returns the value of the sourceAddress record component.
      Returns:
      the value of the sourceAddress record component
    • destinationAddress

      public String destinationAddress()
      Returns the value of the destinationAddress record component.
      Returns:
      the value of the destinationAddress record component
    • sourcePort

      public int sourcePort()
      Returns the value of the sourcePort record component.
      Returns:
      the value of the sourcePort record component
    • destinationPort

      public int destinationPort()
      Returns the value of the destinationPort record component.
      Returns:
      the value of the destinationPort record component