Class IceResponder
Answers connectivity checks from joiners and sends its own back along the same path, which is what opens this host's NAT. It never orders pairs or nominates: the joiner is the controlling agent because it owns the socket the handshake runs over.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceSends a datagram on the listener's socket. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DurationSpacing between outbound checks, matching the client's Ta. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRemoteCandidates(String localUfrag, List<InetSocketAddress> candidates) Adds addresses to probe for an existing session, which is how a trickled candidate reaches the prober after the session was registered.booleanaddSession(IceCredentials local, IceCredentials remote) Registers a peer this host expects to hear from.booleanaddSession(IceCredentials local, IceCredentials remote, List<InetSocketAddress> remoteCandidates) Registers a peer and the addresses to probe.voidclear()Drops every session, for when the world stops accepting remote joins.voidhandleDatagram(SocketAddress source, ByteBuffer datagram) Handles one STUN datagram from the listener's reader thread.booleanisValidated(InetSocketAddress address) Whether a peer address has passed an authenticated connectivity check.voidremoveSession(String localUfrag) Drops a peer's registration.intvoidtick()Sends any outbound checks that are due.
-
Field Details
-
CHECK_INTERVAL
Spacing between outbound checks, matching the client's Ta. Pacing keeps a burst of probes from looking like a port scan to the NAT in front of this host.
-
-
Constructor Details
-
IceResponder
-
-
Method Details
-
addSession
Registers a peer this host expects to hear from.- Returns:
- false when the peer's credentials are malformed or the session limit is reached
-
addSession
public boolean addSession(@Nonnull IceCredentials local, @Nonnull IceCredentials remote, @Nonnull List<InetSocketAddress> remoteCandidates) Registers a peer and the addresses to probe.- Parameters:
remoteCandidates- addresses the joiner offered, screened by the caller
-
addRemoteCandidates
public void addRemoteCandidates(@Nonnull String localUfrag, @Nonnull List<InetSocketAddress> candidates) Adds addresses to probe for an existing session, which is how a trickled candidate reaches the prober after the session was registered. -
removeSession
Drops a peer's registration.Always removes. This is the host's only way to revoke a peer it has rejected, so it must not be conditional on what the peer has done. An ordinary signaling close does not reach here: the host leaves that session to the idle timeout, because the joiner closes signaling before its connection exists and then re-proves the path with consent checks.
-
clear
public void clear()Drops every session, for when the world stops accepting remote joins. -
sessionCount
public int sessionCount() -
isValidated
Whether a peer address has passed an authenticated connectivity check. The QUIC layer uses this to tell a negotiated peer from an unsolicited one. -
handleDatagram
Handles one STUN datagram from the listener's reader thread.Must not block. The reader is the only thread draining the socket, so anything slow here stalls inbound traffic for every connection on this listener.
-
tick
public void tick()Sends any outbound checks that are due.Runs on a scheduler, not the listener's reader thread: that thread is the only one draining the socket, so anything sending from it stalls inbound traffic for every connection.
-