forked from netty/netty
-
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.
If user explicit ask to use an Inet6Address we should try to do so in… (
netty#10415) Motivation: Even if the system does not support ipv6 we should try to use it if the user explicit pass an Inet6Address. This way we ensure we fail and not try to convert this to an ipv4 address internally. This incorrect behavior was introduced by netty@70731bf Modifications: If the user explicit passed an Inet6Address we force the usage of ipv6 Result: Fixes netty#10402
- Loading branch information
1 parent
b1d3aad
commit 4b7dba1
Showing
2 changed files
with
70 additions
and
7 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
transport-native-epoll/src/test/java/io/netty/channel/epoll/LinuxSocketTest.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,54 @@ | ||
/* | ||
* Copyright 2020 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: | ||
* | ||
* http://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.channel.epoll; | ||
|
||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
import java.net.InetAddress; | ||
import java.net.InetSocketAddress; | ||
|
||
import static org.junit.Assume.assumeTrue; | ||
|
||
public class LinuxSocketTest { | ||
@BeforeClass | ||
public static void loadJNI() { | ||
assumeTrue(Epoll.isAvailable()); | ||
} | ||
|
||
@Test(expected = IOException.class) | ||
public void testBindNonIpv6SocketToInet6AddressThrows() throws Exception { | ||
LinuxSocket socket = LinuxSocket.newSocketStream(false); | ||
try { | ||
socket.bind(new InetSocketAddress(InetAddress.getByAddress( | ||
new byte[]{'0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1'}), 0)); | ||
} finally { | ||
socket.close(); | ||
} | ||
} | ||
|
||
@Test(expected = IOException.class) | ||
public void testConnectNonIpv6SocketToInet6AddressThrows() throws Exception { | ||
LinuxSocket socket = LinuxSocket.newSocketStream(false); | ||
try { | ||
socket.connect(new InetSocketAddress(InetAddress.getByAddress( | ||
new byte[]{'0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1'}), 1234)); | ||
} finally { | ||
socket.close(); | ||
} | ||
} | ||
} |
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