Package org.microproxy.udp
Interface UdpContext
public interface UdpContext
One UDP flow, as a
UdpInterceptor sees it: where it goes, and a way to add datagrams.
The same context is given to every hook call of the flow, so it can serve as a key for per-flow
state.-
Method Summary
Modifier and TypeMethodDescriptionThe client's address.longThe client connection the flow belongs to (FlowContext.getConnectionId()).The exchange that opened the flow (its CONNECT-UDP request, on its own HTTP/3 stream).host()The host the flow goes to, as the CONNECT-UDP request named it.intport()The port the flow goes to.voidsend(boolean fromClient, byte[] data) Sends a datagram as if one side had sent it: withfromClientit goes to the target, else to the client.The address the flow's socket is connected to: the target, resolved.
-
Method Details
-
connectionId
long connectionId()The client connection the flow belongs to (FlowContext.getConnectionId()).- Returns:
- the client connection's id
-
clientAddress
InetSocketAddress clientAddress()The client's address.- Returns:
- the client address
-
host
String host()The host the flow goes to, as the CONNECT-UDP request named it.- Returns:
- the target host name or IP address (IPv6 without brackets)
-
port
int port()The port the flow goes to.- Returns:
- the target port
-
targetAddress
InetSocketAddress targetAddress()The address the flow's socket is connected to: the target, resolved.- Returns:
- the target's address
-
flowContext
FlowContext flowContext()The exchange that opened the flow (its CONNECT-UDP request, on its own HTTP/3 stream).- Returns:
- the flow context
-
send
void send(boolean fromClient, byte[] data) Sends a datagram as if one side had sent it: withfromClientit goes to the target, else to the client. It does not pass throughUdpInterceptor.udpMessage(org.microproxy.udp.UdpMessage, org.microproxy.udp.UdpContext), and is queued as relayed datagrams are, so it may be dropped as they may.- Parameters:
fromClient- true to send to the target, false to send to the clientdata- the payload of one datagram- Throws:
IllegalStateException- if the flow has endedNullPointerException- ifdatais null
-