Package tel.schich.libdatachannel
Class IceUdpMuxListener
java.lang.Object
tel.schich.libdatachannel.IceUdpMuxListener
- All Implemented Interfaces:
AutoCloseable
Accepts incoming ICE connections on one UDP endpoint. Native code retains the
first STUN request while the application decides; packets never pass through Java.
Accepted peers are caller-owned and should be closed before this listener.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classSettings returned by application admission.static interfacestatic final classParsed, untrusted metadata from an incoming STUN request.static final classSnapshot of native listener activity. -
Constructor Summary
ConstructorsConstructorDescriptionIceUdpMuxListener(InetAddress bindAddress, int port, int maxPendingRequests, Duration requestTimeout, Executor executor, IceUdpMuxListener.Handler handler) IceUdpMuxListener(InetAddress bindAddress, int port, Executor executor, IceUdpMuxListener.Handler handler) -
Method Summary
Modifier and TypeMethodDescriptionvoidHands every request to the handler again.voidclose()@Nullable Throwablefailure()An admission infrastructure failure, for diagnostics.monitorStun(String serverHost, int serverPort) Starts caller-owned STUN monitoring on this listener's exact native socket.static @Nullable InetSocketAddressproxyRelay(@Nullable InetAddress bindAddress, int port, InetSocketAddress client) The relay a client comes through on a port with PROXY protocol relays, by the address and port its header declared, which is how the client's peer reports it.voidsetAdmission(byte[] context, Map<String, byte[]> secretsByUfragPrefix) Drops requests that neither a key nor a peer on this endpoint authenticates, natively and before the handler runs.static voidsetProxyProtocol(@Nullable InetAddress bindAddress, int port, Collection<String> proxies) Reads a PROXY protocol v2 header from these relays, as numeric addresses or CIDR ranges, on a shared ICE UDP port, for listeners and peers alike, and attributes their datagrams to the client the header declares.long[]stats()Deprecated.
-
Constructor Details
-
IceUdpMuxListener
public IceUdpMuxListener(InetAddress bindAddress, int port, Executor executor, IceUdpMuxListener.Handler handler) -
IceUdpMuxListener
public IceUdpMuxListener(InetAddress bindAddress, int port, int maxPendingRequests, Duration requestTimeout, Executor executor, IceUdpMuxListener.Handler handler)
-
-
Method Details
-
failure
An admission infrastructure failure, for diagnostics. -
statistics
-
monitorStun
Starts caller-owned STUN monitoring on this listener's exact native socket. No peer or data channel is created. Close the returned monitor separately; closing this listener leaves its monitor and already accepted peers owned by their callers. -
setAdmission
Drops requests that neither a key nor a peer on this endpoint authenticates, natively and before the handler runs. A request whose local ufrag starts with a key's prefix authenticates with BASE64(HMAC-SHA256(secret, context || local ufrag)[0..24]). Secrets are copied. Limits: 8 keys, 1 to 16 character prefixes, 1 to 64 byte secrets and a 1024 byte context. -
clearAdmission
public void clearAdmission()Hands every request to the handler again. -
setProxyProtocol
public static void setProxyProtocol(@Nullable InetAddress bindAddress, int port, Collection<String> proxies) Reads a PROXY protocol v2 header from these relays, as numeric addresses or CIDR ranges, on a shared ICE UDP port, for listeners and peers alike, and attributes their datagrams to the client the header declares. Replies go back through the relay, so a relay must use one source port per client, and nothing else leaves the port straight but STUN server lookups. Other incoming datagrams are dropped except STUN responses to the port's own requests. The port stays open while set. A new list keeps the clients of relays it still lists, and an empty one clears it. The bind address must match the peers' or listener's, where a wildcard and null are the same port. -
proxyRelay
public static @Nullable InetSocketAddress proxyRelay(@Nullable InetAddress bindAddress, int port, InetSocketAddress client) The relay a client comes through on a port with PROXY protocol relays, by the address and port its header declared, which is how the client's peer reports it.- Returns:
- The relay, or null when none speaks for the client, also when none are set
-
stats
Deprecated.Usestatistics()for named counters. -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
statistics()for named counters.