Class IceResponder

java.lang.Object
com.hypixel.hytale.server.core.io.ice.IceResponder

public final class IceResponder extends Object
The controlled half of ICE, running on the socket that carries QUIC.

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:
  • Field Details

    • CHECK_INTERVAL

      public static final Duration 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

  • Method Details

    • addSession

      public boolean addSession(@Nonnull IceCredentials local, @Nonnull IceCredentials remote)
      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

      public void removeSession(@Nonnull String localUfrag)
      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

      public boolean isValidated(@Nonnull InetSocketAddress address)
      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

      public void handleDatagram(@Nonnull SocketAddress source, @Nonnull ByteBuffer datagram)
      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.