Package org.microproxy.tcp
Class TcpMessage
java.lang.Object
org.microproxy.tcp.TcpMessage
Bytes the proxy read from one side of a raw TCP tunnel, as a
TcpInterceptor sees them.
TCP is a byte stream, not a sequence of messages: a message is whatever one read returned, so the peer's writes may arrive split into several messages or joined into one, differently from one run to the next. A hook that looks for a line or a command must allow for it starting in one message and ending in the next.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]data()The bytes as read.booleanReturns whether the client sent the bytes (going to the server), rather than the server.intlength()Returns the number of bytes.text()The bytes decoded as UTF-8, malformed sequences replaced with U+FFFD.Returns when the proxy read the bytes.toString()withData(byte[] data) A copy of this message with other bytes, the same direction and timestamp.A copy of this message with the UTF-8 encoding oftext.
-
Constructor Details
-
TcpMessage
A message.- Parameters:
data- the bytes, which the message holds as they are (not copied)fromClient- whether the client sent them, rather than the servertimestamp- when the proxy read them
-
-
Method Details
-
data
public byte[] data()The bytes as read. The array is the message's own, not a copy: an interceptor may change it in place and return it.- Returns:
- the bytes
-
length
public int length()Returns the number of bytes.- Returns:
- the number of bytes
-
fromClient
public boolean fromClient()Returns whether the client sent the bytes (going to the server), rather than the server.- Returns:
- whether the client sent the bytes (going to the server), rather than the server
-
timestamp
Returns when the proxy read the bytes.- Returns:
- when the proxy read the bytes
-
text
The bytes decoded as UTF-8, malformed sequences replaced with U+FFFD. A character split between two messages shows as replacement characters in both.- Returns:
- the text
-
withData
A copy of this message with other bytes, the same direction and timestamp.- Parameters:
data- the bytes of the copy (not copied)- Returns:
- the copy
-
withText
A copy of this message with the UTF-8 encoding oftext.- Parameters:
text- the text of the copy- Returns:
- the copy
-
toString
-