forked from java-native-access/jna
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
QuicTokenHandler: expose max connection id length, fix endianness (ja…
…va-native-access#732) Motivation: The ByteBuf that is passed into the `writeToken(...)` method should use `BIG_ENDIAN` while at the moment it might use `LITTLE_ENDIAN`. Modifications: * Ensures that all buffers passed to the `QuicTokenHandler` are now big endian * Expose max connection it via static field in Quic class. Result: Fixes java-native-access#731. --------- Co-authored-by: Norman Maurer <[email protected]>
- Loading branch information
1 parent
150a83d
commit 156ce3e
Showing
7 changed files
with
72 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
codec-native-quic/src/test/java/io/netty/incubator/codec/quic/TestQuicTokenHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright 2024 The Netty Project | ||
* | ||
* The Netty Project licenses this file to you under the Apache License, | ||
* version 2.0 (the "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at: | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package io.netty.incubator.codec.quic; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
|
||
import java.net.InetSocketAddress; | ||
import java.nio.ByteOrder; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
final class TestQuicTokenHandler implements QuicTokenHandler { | ||
public static final QuicTokenHandler INSTANCE = new TestQuicTokenHandler(); | ||
|
||
@Override | ||
@SuppressWarnings("deprecation") | ||
public boolean writeToken(ByteBuf out, ByteBuf dcid, InetSocketAddress address) { | ||
assertEquals(ByteOrder.BIG_ENDIAN, out.order()); | ||
return InsecureQuicTokenHandler.INSTANCE.writeToken(out, dcid, address); | ||
} | ||
|
||
@Override | ||
@SuppressWarnings("deprecation") | ||
public int validateToken(ByteBuf token, InetSocketAddress address) { | ||
assertEquals(ByteOrder.BIG_ENDIAN, token.order()); | ||
return InsecureQuicTokenHandler.INSTANCE.validateToken(token, address); | ||
} | ||
|
||
@Override | ||
public int maxTokenLength() { | ||
return InsecureQuicTokenHandler.INSTANCE.maxTokenLength(); | ||
} | ||
|
||
private TestQuicTokenHandler() { } | ||
} |