From c117fbc61a69e22ca1de946785a64ae9bebb2258 Mon Sep 17 00:00:00 2001 From: Ludovic Orban Date: Mon, 29 Mar 2021 11:05:49 +0200 Subject: [PATCH] todos and cleanups Signed-off-by: Ludovic Orban --- .../jetty/http3/common/QuicConnection.java | 1 + .../jetty/http3/common/QuicDatagramEndPoint.java | 15 ++++++++++----- .../eclipse/jetty/http3/common/QuicSession.java | 1 + .../jetty/http3/server/ServerQuicConnection.java | 3 +++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/jetty-http3/http3-common/src/main/java/org/eclipse/jetty/http3/common/QuicConnection.java b/jetty-http3/http3-common/src/main/java/org/eclipse/jetty/http3/common/QuicConnection.java index 653da7a5866..b2b24c7408f 100644 --- a/jetty-http3/http3-common/src/main/java/org/eclipse/jetty/http3/common/QuicConnection.java +++ b/jetty-http3/http3-common/src/main/java/org/eclipse/jetty/http3/common/QuicConnection.java @@ -78,6 +78,7 @@ public abstract class QuicConnection extends AbstractConnection { try { + // TODO make the buffer size configurable ByteBuffer cipherBuffer = byteBufferPool.acquire(LibQuiche.QUICHE_MIN_CLIENT_INITIAL_LEN, true); while (true) { diff --git a/jetty-http3/http3-common/src/main/java/org/eclipse/jetty/http3/common/QuicDatagramEndPoint.java b/jetty-http3/http3-common/src/main/java/org/eclipse/jetty/http3/common/QuicDatagramEndPoint.java index 9f6b8a8b841..990f6c75966 100644 --- a/jetty-http3/http3-common/src/main/java/org/eclipse/jetty/http3/common/QuicDatagramEndPoint.java +++ b/jetty-http3/http3-common/src/main/java/org/eclipse/jetty/http3/common/QuicDatagramEndPoint.java @@ -37,6 +37,16 @@ public class QuicDatagramEndPoint extends AbstractEndPoint implements ManagedSel { private static final Logger LOG = LoggerFactory.getLogger(QuicDatagramEndPoint.class); + /** + * {@link #fill(ByteBuffer)} needs to pass the {@link InetSocketAddress} together with the buffer + * and {@link #flush(ByteBuffer...)} needs the {@link InetSocketAddress} passed together with the buffer. + * Since we cannot change the {@link org.eclipse.jetty.io.EndPoint} API, the {@link InetSocketAddress} + * argument must be passed on the side with this thread-local. + * + * Note: a first implementation was encoding the InetSocketAddress in the buffer(s) but this was as complex + * and required a mildly expensive encode-decode cycle each time one of those two methods was called. + * This mechanism is as complex and brittle but virtually as cheap as standard argument passing. + */ public static InetAddressArgument INET_ADDRESS_ARGUMENT = new InetAddressArgument(); private final AutoLock _lock = new AutoLock(); @@ -272,11 +282,6 @@ public class QuicDatagramEndPoint extends AbstractEndPoint implements ManagedSel return flushedAll; } - public DatagramChannel getChannel() - { - return _channel; - } - @Override public Object getTransport() { diff --git a/jetty-http3/http3-common/src/main/java/org/eclipse/jetty/http3/common/QuicSession.java b/jetty-http3/http3-common/src/main/java/org/eclipse/jetty/http3/common/QuicSession.java index b391d57eba2..ddb58129c57 100644 --- a/jetty-http3/http3-common/src/main/java/org/eclipse/jetty/http3/common/QuicSession.java +++ b/jetty-http3/http3-common/src/main/java/org/eclipse/jetty/http3/common/QuicSession.java @@ -297,6 +297,7 @@ public abstract class QuicSession @Override protected Action process() throws IOException { + // TODO make the buffer size configurable cipherBuffer = byteBufferPool.acquire(LibQuiche.QUICHE_MIN_CLIENT_INITIAL_LEN, true); int pos = BufferUtil.flipToFill(cipherBuffer); int drained = quicheConnection.drainCipherText(cipherBuffer); diff --git a/jetty-http3/http3-server/src/main/java/org/eclipse/jetty/http3/server/ServerQuicConnection.java b/jetty-http3/http3-server/src/main/java/org/eclipse/jetty/http3/server/ServerQuicConnection.java index 7dc617262df..366ba75c372 100644 --- a/jetty-http3/http3-server/src/main/java/org/eclipse/jetty/http3/server/ServerQuicConnection.java +++ b/jetty-http3/http3-server/src/main/java/org/eclipse/jetty/http3/server/ServerQuicConnection.java @@ -59,11 +59,14 @@ public class ServerQuicConnection extends QuicConnection protected QuicSession createSession(InetSocketAddress remoteAddress, ByteBuffer cipherBuffer) throws IOException { ByteBufferPool byteBufferPool = getByteBufferPool(); + // TODO make the token validator configurable QuicheConnection quicheConnection = QuicheConnection.tryAccept(quicheConfig, new SimpleTokenValidator(remoteAddress), cipherBuffer); if (quicheConnection == null) { + // TODO make the buffer size configurable ByteBuffer negotiationBuffer = byteBufferPool.acquire(LibQuiche.QUICHE_MIN_CLIENT_INITIAL_LEN, true); int pos = BufferUtil.flipToFill(negotiationBuffer); + // TODO make the token minter configurable if (!QuicheConnection.negotiate(new SimpleTokenMinter(remoteAddress), cipherBuffer, negotiationBuffer)) { if (LOG.isDebugEnabled())