diff --git a/documentation/jetty-documentation/src/main/java/org/eclipse/jetty/docs/programming/server/http2/HTTP2ServerDocs.java b/documentation/jetty-documentation/src/main/java/org/eclipse/jetty/docs/programming/server/http2/HTTP2ServerDocs.java
index cdec93abd224..5e6b0dbfd219 100644
--- a/documentation/jetty-documentation/src/main/java/org/eclipse/jetty/docs/programming/server/http2/HTTP2ServerDocs.java
+++ b/documentation/jetty-documentation/src/main/java/org/eclipse/jetty/docs/programming/server/http2/HTTP2ServerDocs.java
@@ -13,7 +13,7 @@
package org.eclipse.jetty.docs.programming.server.http2;
-import java.net.InetSocketAddress;
+import java.net.SocketAddress;
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;
@@ -82,7 +82,7 @@ public void accept()
@Override
public void onAccept(Session session)
{
- InetSocketAddress remoteAddress = session.getRemoteAddress();
+ SocketAddress remoteAddress = session.getRemoteSocketAddress();
System.getLogger("http2").log(INFO, "Connection from {0}", remoteAddress);
}
};
diff --git a/jetty-client/src/main/java/module-info.java b/jetty-client/src/main/java/module-info.java
index 9068b49799ee..31515a9388f3 100644
--- a/jetty-client/src/main/java/module-info.java
+++ b/jetty-client/src/main/java/module-info.java
@@ -18,7 +18,6 @@
exports org.eclipse.jetty.client.dynamic;
exports org.eclipse.jetty.client.http;
exports org.eclipse.jetty.client.jmx to org.eclipse.jetty.jmx;
- exports org.eclipse.jetty.client.proxy;
exports org.eclipse.jetty.client.util;
requires org.eclipse.jetty.alpn.client;
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractConnectorHttpClientTransport.java b/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractConnectorHttpClientTransport.java
index 478ec63b0239..77a7f2255479 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractConnectorHttpClientTransport.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractConnectorHttpClientTransport.java
@@ -14,6 +14,7 @@
package org.eclipse.jetty.client;
import java.net.InetSocketAddress;
+import java.net.SocketAddress;
import java.time.Duration;
import java.util.Map;
import java.util.Objects;
@@ -62,7 +63,7 @@ protected void doStart() throws Exception
}
@Override
- public void connect(InetSocketAddress address, Map context)
+ public void connect(SocketAddress address, Map context)
{
HttpDestination destination = (HttpDestination)context.get(HTTP_DESTINATION_CONTEXT_KEY);
context.put(ClientConnector.CLIENT_CONNECTION_FACTORY_CONTEXT_KEY, destination.getClientConnectionFactory());
@@ -71,4 +72,10 @@ public void connect(InetSocketAddress address, Map context)
context.put(ClientConnector.CONNECTION_PROMISE_CONTEXT_KEY, Promise.from(ioConnection -> {}, promise::failed));
connector.connect(address, context);
}
+
+ @Override
+ public void connect(InetSocketAddress address, Map context)
+ {
+ connect((SocketAddress)address, context);
+ }
}
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java
index 7e672fd42b55..84f19e47f9a6 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java
@@ -590,7 +590,7 @@ public void failed(Throwable x)
connect(socketAddresses, nextIndex, context);
}
});
- transport.connect(socketAddresses.get(index), context);
+ transport.connect((SocketAddress)socketAddresses.get(index), context);
}
});
}
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClientTransport.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClientTransport.java
index 3b9aefe42ebf..41ac7b4f722d 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClientTransport.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClientTransport.java
@@ -14,6 +14,7 @@
package org.eclipse.jetty.client;
import java.net.InetSocketAddress;
+import java.net.SocketAddress;
import java.util.Map;
import org.eclipse.jetty.io.ClientConnectionFactory;
@@ -69,9 +70,25 @@ public interface HttpClientTransport extends ClientConnectionFactory
*
* @param address the address to connect to
* @param context the context information to establish the connection
+ * @deprecated use {@link #connect(SocketAddress, Map)} instead.
*/
+ @Deprecated
public void connect(InetSocketAddress address, Map context);
+ /**
+ * Establishes a physical connection to the given {@code address}.
+ *
+ * @param address the address to connect to
+ * @param context the context information to establish the connection
+ */
+ public default void connect(SocketAddress address, Map context)
+ {
+ if (address instanceof InetSocketAddress)
+ connect((InetSocketAddress)address, context);
+ else
+ throw new UnsupportedOperationException("Unsupported SocketAddress " + address);
+ }
+
/**
* @return the factory for ConnectionPool instances
*/
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/ProxyProtocolClientConnectionFactory.java b/jetty-client/src/main/java/org/eclipse/jetty/client/ProxyProtocolClientConnectionFactory.java
index 52d4ce130a0b..4e9363a5c58c 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/ProxyProtocolClientConnectionFactory.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/ProxyProtocolClientConnectionFactory.java
@@ -16,6 +16,7 @@
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.InetSocketAddress;
+import java.net.SocketAddress;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
@@ -60,10 +61,18 @@ protected ProxyProtocolConnection newProxyProtocolConnection(EndPoint endPoint,
Tag tag = (Tag)destination.getOrigin().getTag();
if (tag == null)
{
- InetSocketAddress local = endPoint.getLocalAddress();
- InetSocketAddress remote = endPoint.getRemoteAddress();
- boolean ipv4 = local.getAddress() instanceof Inet4Address;
- tag = new Tag(ipv4 ? "TCP4" : "TCP6", local.getAddress().getHostAddress(), local.getPort(), remote.getAddress().getHostAddress(), remote.getPort());
+ SocketAddress local = endPoint.getLocalSocketAddress();
+ InetSocketAddress inetLocal = local instanceof InetSocketAddress ? (InetSocketAddress)local : null;
+ InetAddress localAddress = inetLocal == null ? null : inetLocal.getAddress();
+ SocketAddress remote = endPoint.getRemoteSocketAddress();
+ InetSocketAddress inetRemote = remote instanceof InetSocketAddress ? (InetSocketAddress)remote : null;
+ InetAddress remoteAddress = inetRemote == null ? null : inetRemote.getAddress();
+ String family = local == null || inetLocal == null ? "UNKNOWN" : localAddress instanceof Inet4Address ? "TCP4" : "TCP6";
+ tag = new Tag(family,
+ localAddress == null ? null : localAddress.getHostAddress(),
+ inetLocal == null ? 0 : inetLocal.getPort(),
+ remoteAddress == null ? null : remoteAddress.getHostAddress(),
+ inetRemote == null ? 0 : inetRemote.getPort());
}
return new ProxyProtocolConnectionV1(endPoint, executor, getClientConnectionFactory(), context, tag);
}
@@ -198,10 +207,21 @@ protected ProxyProtocolConnection newProxyProtocolConnection(EndPoint endPoint,
Tag tag = (Tag)destination.getOrigin().getTag();
if (tag == null)
{
- InetSocketAddress local = endPoint.getLocalAddress();
- InetSocketAddress remote = endPoint.getRemoteAddress();
- boolean ipv4 = local.getAddress() instanceof Inet4Address;
- tag = new Tag(Tag.Command.PROXY, ipv4 ? Tag.Family.INET4 : Tag.Family.INET6, Tag.Protocol.STREAM, local.getAddress().getHostAddress(), local.getPort(), remote.getAddress().getHostAddress(), remote.getPort(), null);
+ SocketAddress local = endPoint.getLocalSocketAddress();
+ InetSocketAddress inetLocal = local instanceof InetSocketAddress ? (InetSocketAddress)local : null;
+ InetAddress localAddress = inetLocal == null ? null : inetLocal.getAddress();
+ SocketAddress remote = endPoint.getRemoteSocketAddress();
+ InetSocketAddress inetRemote = remote instanceof InetSocketAddress ? (InetSocketAddress)remote : null;
+ InetAddress remoteAddress = inetRemote == null ? null : inetRemote.getAddress();
+ Tag.Family family = local == null || inetLocal == null ? Tag.Family.UNSPEC : localAddress instanceof Inet4Address ? Tag.Family.INET4 : Tag.Family.INET6;
+ tag = new Tag(Tag.Command.PROXY,
+ family,
+ Tag.Protocol.STREAM,
+ localAddress == null ? null : localAddress.getHostAddress(),
+ inetLocal == null ? 0 : inetLocal.getPort(),
+ remoteAddress == null ? null : remoteAddress.getHostAddress(),
+ inetRemote == null ? 0 : inetRemote.getPort(),
+ null);
}
return new ProxyProtocolConnectionV2(endPoint, executor, getClientConnectionFactory(), context, tag);
}
@@ -220,14 +240,14 @@ public static class Tag implements ClientConnectionFactory.Decorator
*/
public static final Tag LOCAL = new Tag(Command.LOCAL, Family.UNSPEC, Protocol.UNSPEC, null, 0, null, 0, null);
- private Command command;
- private Family family;
- private Protocol protocol;
- private String srcIP;
- private int srcPort;
- private String dstIP;
- private int dstPort;
- private List tlvs;
+ private final Command command;
+ private final Family family;
+ private final Protocol protocol;
+ private final String srcIP;
+ private final int srcPort;
+ private final String dstIP;
+ private final int dstPort;
+ private final List tlvs;
/**
* Creates a Tag whose metadata will be derived from the underlying EndPoint.
@@ -514,32 +534,36 @@ protected void writePROXYBytes(EndPoint endPoint, Callback callback)
{
try
{
- InetSocketAddress localAddress = endPoint.getLocalAddress();
- InetSocketAddress remoteAddress = endPoint.getRemoteAddress();
+ SocketAddress local = endPoint.getLocalSocketAddress();
+ InetSocketAddress inetLocal = local instanceof InetSocketAddress ? (InetSocketAddress)local : null;
+ InetAddress localAddress = inetLocal == null ? null : inetLocal.getAddress();
+ SocketAddress remote = endPoint.getRemoteSocketAddress();
+ InetSocketAddress inetRemote = remote instanceof InetSocketAddress ? (InetSocketAddress)remote : null;
+ InetAddress remoteAddress = inetRemote == null ? null : inetRemote.getAddress();
String family = tag.getFamily();
String srcIP = tag.getSourceAddress();
int srcPort = tag.getSourcePort();
String dstIP = tag.getDestinationAddress();
int dstPort = tag.getDestinationPort();
if (family == null)
- family = localAddress.getAddress() instanceof Inet4Address ? "TCP4" : "TCP6";
+ family = local == null || inetLocal == null ? "UNKNOWN" : localAddress instanceof Inet4Address ? "TCP4" : "TCP6";
family = family.toUpperCase(Locale.ENGLISH);
boolean unknown = family.equals("UNKNOWN");
StringBuilder builder = new StringBuilder(64);
builder.append("PROXY ").append(family);
if (!unknown)
{
- if (srcIP == null)
- srcIP = localAddress.getAddress().getHostAddress();
+ if (srcIP == null && localAddress != null)
+ srcIP = localAddress.getHostAddress();
builder.append(" ").append(srcIP);
- if (dstIP == null)
- dstIP = remoteAddress.getAddress().getHostAddress();
+ if (dstIP == null && remoteAddress != null)
+ dstIP = remoteAddress.getHostAddress();
builder.append(" ").append(dstIP);
- if (srcPort <= 0)
- srcPort = localAddress.getPort();
+ if (srcPort <= 0 && inetLocal != null)
+ srcPort = inetLocal.getPort();
builder.append(" ").append(srcPort);
- if (dstPort <= 0)
- dstPort = remoteAddress.getPort();
+ if (dstPort <= 0 && inetRemote != null)
+ dstPort = inetRemote.getPort();
builder.append(" ").append(dstPort);
}
builder.append("\r\n");
@@ -590,16 +614,19 @@ protected void writePROXYBytes(EndPoint endPoint, Callback callback)
buffer.put((byte)versionAndCommand);
V2.Tag.Family family = tag.getFamily();
String srcAddr = tag.getSourceAddress();
- if (srcAddr == null)
- srcAddr = endPoint.getLocalAddress().getAddress().getHostAddress();
+ SocketAddress local = endPoint.getLocalSocketAddress();
+ InetSocketAddress inetLocal = local instanceof InetSocketAddress ? (InetSocketAddress)local : null;
+ InetAddress localAddress = inetLocal == null ? null : inetLocal.getAddress();
+ if (srcAddr == null && localAddress != null)
+ srcAddr = localAddress.getHostAddress();
int srcPort = tag.getSourcePort();
- if (srcPort <= 0)
- srcPort = endPoint.getLocalAddress().getPort();
+ if (srcPort <= 0 && inetLocal != null)
+ srcPort = inetLocal.getPort();
if (family == null)
- family = InetAddress.getByName(srcAddr) instanceof Inet4Address ? V2.Tag.Family.INET4 : V2.Tag.Family.INET6;
+ family = local == null || inetLocal == null ? V2.Tag.Family.UNSPEC : localAddress instanceof Inet4Address ? V2.Tag.Family.INET4 : V2.Tag.Family.INET6;
V2.Tag.Protocol protocol = tag.getProtocol();
if (protocol == null)
- protocol = V2.Tag.Protocol.STREAM;
+ protocol = local == null ? V2.Tag.Protocol.UNSPEC : V2.Tag.Protocol.STREAM;
int familyAndProtocol = (family.ordinal() << 4) | protocol.ordinal();
buffer.put((byte)familyAndProtocol);
int length = 0;
@@ -622,11 +649,14 @@ protected void writePROXYBytes(EndPoint endPoint, Callback callback)
length += vectorsLength;
buffer.putShort((short)length);
String dstAddr = tag.getDestinationAddress();
- if (dstAddr == null)
- dstAddr = endPoint.getRemoteAddress().getAddress().getHostAddress();
+ SocketAddress remote = endPoint.getRemoteSocketAddress();
+ InetSocketAddress inetRemote = remote instanceof InetSocketAddress ? (InetSocketAddress)remote : null;
+ InetAddress remoteAddress = inetRemote == null ? null : inetRemote.getAddress();
+ if (dstAddr == null && remoteAddress != null)
+ dstAddr = remoteAddress.getHostAddress();
int dstPort = tag.getDestinationPort();
- if (dstPort <= 0)
- dstPort = endPoint.getRemoteAddress().getPort();
+ if (dstPort <= 0 && inetRemote != null)
+ dstPort = inetRemote.getPort();
switch (family)
{
case UNSPEC:
@@ -640,9 +670,14 @@ protected void writePROXYBytes(EndPoint endPoint, Callback callback)
break;
case UNIX:
int position = buffer.position();
- buffer.put(srcAddr.getBytes(StandardCharsets.US_ASCII));
- buffer.position(position + 108);
- buffer.put(dstAddr.getBytes(StandardCharsets.US_ASCII));
+ if (srcAddr != null)
+ buffer.put(srcAddr.getBytes(StandardCharsets.US_ASCII));
+ position = position + 108;
+ buffer.position(position);
+ if (dstAddr != null)
+ buffer.put(dstAddr.getBytes(StandardCharsets.US_ASCII));
+ position = position + 108;
+ buffer.position(position);
break;
default:
throw new IllegalStateException();
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpConnectionOverHTTP.java b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpConnectionOverHTTP.java
index 8ba22b8b3c6c..5a397b53e9c0 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpConnectionOverHTTP.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpConnectionOverHTTP.java
@@ -256,8 +256,8 @@ public String toConnectionString()
return String.format("%s@%x(l:%s <-> r:%s,closed=%b)=>%s",
getClass().getSimpleName(),
hashCode(),
- getEndPoint().getLocalAddress(),
- getEndPoint().getRemoteAddress(),
+ getEndPoint().getLocalSocketAddress(),
+ getEndPoint().getRemoteSocketAddress(),
closed.get(),
channel);
}
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/proxy/ProxyProtocolClientConnectionFactory.java b/jetty-client/src/main/java/org/eclipse/jetty/client/proxy/ProxyProtocolClientConnectionFactory.java
deleted file mode 100644
index 707c025fa7de..000000000000
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/proxy/ProxyProtocolClientConnectionFactory.java
+++ /dev/null
@@ -1,139 +0,0 @@
-//
-// ========================================================================
-// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
-//
-// This program and the accompanying materials are made available under the
-// terms of the Eclipse Public License v. 2.0 which is available at
-// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
-// which is available at https://www.apache.org/licenses/LICENSE-2.0.
-//
-// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
-// ========================================================================
-//
-
-package org.eclipse.jetty.client.proxy;
-
-import java.net.Inet6Address;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.nio.ByteBuffer;
-import java.nio.charset.StandardCharsets;
-import java.util.Map;
-import java.util.concurrent.Executor;
-import java.util.function.Supplier;
-
-import org.eclipse.jetty.client.HttpClientTransport;
-import org.eclipse.jetty.client.HttpDestination;
-import org.eclipse.jetty.client.Origin;
-import org.eclipse.jetty.client.api.Connection;
-import org.eclipse.jetty.io.AbstractConnection;
-import org.eclipse.jetty.io.ClientConnectionFactory;
-import org.eclipse.jetty.io.EndPoint;
-import org.eclipse.jetty.util.Callback;
-import org.eclipse.jetty.util.Promise;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ProxyProtocolClientConnectionFactory implements ClientConnectionFactory
-{
- private final ClientConnectionFactory connectionFactory;
- private final Supplier proxiedAddressSupplier;
-
- public ProxyProtocolClientConnectionFactory(ClientConnectionFactory connectionFactory, Supplier proxiedAddressSupplier)
- {
- this.connectionFactory = connectionFactory;
- this.proxiedAddressSupplier = proxiedAddressSupplier;
- }
-
- @Override
- public org.eclipse.jetty.io.Connection newConnection(EndPoint endPoint, Map context)
- {
- HttpDestination destination = (HttpDestination)context.get(HttpClientTransport.HTTP_DESTINATION_CONTEXT_KEY);
- Executor executor = destination.getHttpClient().getExecutor();
- ProxyProtocolConnection connection = new ProxyProtocolConnection(endPoint, executor, context);
- return customize(connection, context);
- }
-
- private class ProxyProtocolConnection extends AbstractConnection implements Callback
- {
- private final Logger log = LoggerFactory.getLogger(ProxyProtocolConnection.class);
- private final Map context;
-
- public ProxyProtocolConnection(EndPoint endPoint, Executor executor, Map context)
- {
- super(endPoint, executor);
- this.context = context;
- }
-
- @Override
- public void onOpen()
- {
- super.onOpen();
- writePROXYLine();
- }
-
- // @checkstyle-disable-check : MethodNameCheck
-
- protected void writePROXYLine()
- {
- Origin.Address proxiedAddress = proxiedAddressSupplier.get();
- if (proxiedAddress == null)
- {
- failed(new IllegalArgumentException("Missing proxied socket address"));
- return;
- }
- String proxiedIP = proxiedAddress.getHost();
- int proxiedPort = proxiedAddress.getPort();
- InetSocketAddress serverSocketAddress = getEndPoint().getRemoteAddress();
- InetAddress serverAddress = serverSocketAddress.getAddress();
- String serverIP = serverAddress.getHostAddress();
- int serverPort = serverSocketAddress.getPort();
-
- boolean ipv6 = serverAddress instanceof Inet6Address;
- String line = String.format("PROXY %s %s %s %d %d\r\n", ipv6 ? "TCP6" : "TCP4", proxiedIP, serverIP, proxiedPort, serverPort);
- if (log.isDebugEnabled())
- log.debug("Writing PROXY line: {}", line.trim());
- ByteBuffer buffer = ByteBuffer.wrap(line.getBytes(StandardCharsets.US_ASCII));
- getEndPoint().write(this, buffer);
- }
-
- // @checkstyle-enable-check : MethodNameCheck
-
- @Override
- public void succeeded()
- {
- try
- {
- EndPoint endPoint = getEndPoint();
- org.eclipse.jetty.io.Connection connection = connectionFactory.newConnection(endPoint, context);
- if (log.isDebugEnabled())
- log.debug("Written PROXY line, upgrading to {}", connection);
- endPoint.upgrade(connection);
- }
- catch (Throwable x)
- {
- failed(x);
- }
- }
-
- @Override
- public void failed(Throwable x)
- {
- close();
- @SuppressWarnings("unchecked")
- Promise promise = (Promise)context.get(HttpClientTransport.HTTP_CONNECTION_PROMISE_CONTEXT_KEY);
- promise.failed(x);
- }
-
- @Override
- public InvocationType getInvocationType()
- {
- return InvocationType.NON_BLOCKING;
- }
-
- @Override
- public void onFillable()
- {
- }
- }
-}
diff --git a/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpConnectionOverFCGI.java b/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpConnectionOverFCGI.java
index 19ee20518dc5..a78f14ddeb4a 100644
--- a/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpConnectionOverFCGI.java
+++ b/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpConnectionOverFCGI.java
@@ -356,8 +356,8 @@ public String toConnectionString()
return String.format("%s@%x[l:%s<->r:%s]",
getClass().getSimpleName(),
hashCode(),
- getEndPoint().getLocalAddress(),
- getEndPoint().getRemoteAddress());
+ getEndPoint().getLocalSocketAddress(),
+ getEndPoint().getRemoteSocketAddress());
}
private class Delegate extends HttpConnection
diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java
index d98d7fbc4ff0..802718af54bf 100644
--- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java
+++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java
@@ -15,6 +15,7 @@
import java.io.IOException;
import java.net.InetSocketAddress;
+import java.net.SocketAddress;
import java.nio.channels.ClosedChannelException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayDeque;
@@ -902,13 +903,31 @@ public IStream getStream(int streamId)
@Override
public InetSocketAddress getLocalAddress()
{
- return endPoint.getLocalAddress();
+ SocketAddress local = getLocalSocketAddress();
+ if (local instanceof InetSocketAddress)
+ return (InetSocketAddress)local;
+ return null;
+ }
+
+ @Override
+ public SocketAddress getLocalSocketAddress()
+ {
+ return endPoint.getLocalSocketAddress();
}
@Override
public InetSocketAddress getRemoteAddress()
{
- return endPoint.getRemoteAddress();
+ SocketAddress remote = getRemoteSocketAddress();
+ if (remote instanceof InetSocketAddress)
+ return (InetSocketAddress)remote;
+ return null;
+ }
+
+ @Override
+ public SocketAddress getRemoteSocketAddress()
+ {
+ return endPoint.getRemoteSocketAddress();
}
@ManagedAttribute(value = "The flow control send window", readonly = true)
@@ -1190,8 +1209,8 @@ public String toString()
return String.format("%s@%x{local:%s,remote:%s,sendWindow=%s,recvWindow=%s,%s}",
getClass().getSimpleName(),
hashCode(),
- getEndPoint().getLocalAddress(),
- getEndPoint().getRemoteAddress(),
+ getEndPoint().getLocalSocketAddress(),
+ getEndPoint().getRemoteSocketAddress(),
sendWindow,
recvWindow,
streamsState
diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2StreamEndPoint.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2StreamEndPoint.java
index 8ac0b5581e3e..8c95d5f65821 100644
--- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2StreamEndPoint.java
+++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2StreamEndPoint.java
@@ -15,6 +15,7 @@
import java.io.IOException;
import java.net.InetSocketAddress;
+import java.net.SocketAddress;
import java.nio.BufferOverflowException;
import java.nio.ByteBuffer;
import java.nio.channels.ReadPendingException;
@@ -57,13 +58,31 @@ public HTTP2StreamEndPoint(IStream stream)
@Override
public InetSocketAddress getLocalAddress()
{
- return stream.getSession().getLocalAddress();
+ SocketAddress local = getLocalSocketAddress();
+ if (local instanceof InetSocketAddress)
+ return (InetSocketAddress)local;
+ return null;
+ }
+
+ @Override
+ public SocketAddress getLocalSocketAddress()
+ {
+ return stream.getSession().getLocalSocketAddress();
}
@Override
public InetSocketAddress getRemoteAddress()
{
- return stream.getSession().getRemoteAddress();
+ SocketAddress remote = getRemoteSocketAddress();
+ if (remote instanceof InetSocketAddress)
+ return (InetSocketAddress)remote;
+ return null;
+ }
+
+ @Override
+ public SocketAddress getRemoteSocketAddress()
+ {
+ return stream.getSession().getRemoteSocketAddress();
}
@Override
diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/api/Session.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/api/Session.java
index 65db4401ee4e..d09d8d7a7482 100644
--- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/api/Session.java
+++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/api/Session.java
@@ -14,6 +14,7 @@
package org.eclipse.jetty.http2.api;
import java.net.InetSocketAddress;
+import java.net.SocketAddress;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
@@ -137,15 +138,37 @@ public default CompletableFuture newStream(HeadersFrame frame, Stream.Li
/**
* @return the local network address this session is bound to,
* or {@code null} if this session is not bound to a network address
+ * @deprecated use {@link #getLocalSocketAddress()} instead
*/
+ @Deprecated
public InetSocketAddress getLocalAddress();
+ /**
+ * @return the local network address this session is bound to,
+ * or {@code null} if this session is not bound to a network address
+ */
+ public default SocketAddress getLocalSocketAddress()
+ {
+ return getLocalAddress();
+ }
+
/**
* @return the remote network address this session is connected to,
* or {@code null} if this session is not connected to a network address
+ * @deprecated use {@link #getRemoteSocketAddress()} instead
*/
+ @Deprecated
public InetSocketAddress getRemoteAddress();
+ /**
+ * @return the remote network address this session is connected to,
+ * or {@code null} if this session is not connected to a network address
+ */
+ public default SocketAddress getRemoteSocketAddress()
+ {
+ return getRemoteAddress();
+ }
+
/**
* A {@link Listener} is the passive counterpart of a {@link Session} and
* receives events happening on an HTTP/2 connection.
diff --git a/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpClientTransportOverHTTP2.java b/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpClientTransportOverHTTP2.java
index fc7a28ea7044..f316cbedb0eb 100644
--- a/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpClientTransportOverHTTP2.java
+++ b/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpClientTransportOverHTTP2.java
@@ -15,6 +15,7 @@
import java.io.IOException;
import java.net.InetSocketAddress;
+import java.net.SocketAddress;
import java.util.List;
import java.util.Map;
@@ -118,7 +119,7 @@ public HttpDestination newHttpDestination(Origin origin)
}
@Override
- public void connect(InetSocketAddress address, Map context)
+ public void connect(SocketAddress address, Map context)
{
HttpClient httpClient = getHttpClient();
client.setConnectTimeout(httpClient.getConnectTimeout());
@@ -131,11 +132,22 @@ public void connect(InetSocketAddress address, Map context)
connect(address, destination.getClientConnectionFactory(), listenerPromise, listenerPromise, context);
}
- protected void connect(InetSocketAddress address, ClientConnectionFactory factory, Session.Listener listener, Promise promise, Map context)
+ @Override
+ public void connect(InetSocketAddress address, Map context)
+ {
+ connect((SocketAddress)address, context);
+ }
+
+ protected void connect(SocketAddress address, ClientConnectionFactory factory, Session.Listener listener, Promise promise, Map context)
{
getHTTP2Client().connect(address, factory, listener, promise, context);
}
+ protected void connect(InetSocketAddress address, ClientConnectionFactory factory, Session.Listener listener, Promise promise, Map context)
+ {
+ connect((SocketAddress)address, factory, listener, promise, context);
+ }
+
@Override
public org.eclipse.jetty.io.Connection newConnection(EndPoint endPoint, Map context) throws IOException
{
@@ -144,7 +156,7 @@ public org.eclipse.jetty.io.Connection newConnection(EndPoint endPoint, Map promise, Map context)
+ protected void connect(SocketAddress address, ClientConnectionFactory factory, Session.Listener listener, Promise promise, Map context)
{
super.connect(address, factory, new Wrapper(listener)
{
diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractEndPoint.java
index c30fe3652ec9..1ae846463607 100644
--- a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractEndPoint.java
+++ b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractEndPoint.java
@@ -14,6 +14,8 @@
package org.eclipse.jetty.io;
import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
import java.nio.ByteBuffer;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicReference;
@@ -55,6 +57,36 @@ protected AbstractEndPoint(Scheduler scheduler)
super(scheduler);
}
+ @Override
+ public InetSocketAddress getLocalAddress()
+ {
+ SocketAddress local = getLocalSocketAddress();
+ if (local instanceof InetSocketAddress)
+ return (InetSocketAddress)local;
+ return null;
+ }
+
+ @Override
+ public SocketAddress getLocalSocketAddress()
+ {
+ return null;
+ }
+
+ @Override
+ public InetSocketAddress getRemoteAddress()
+ {
+ SocketAddress remote = getRemoteSocketAddress();
+ if (remote instanceof InetSocketAddress)
+ return (InetSocketAddress)remote;
+ return null;
+ }
+
+ @Override
+ public SocketAddress getRemoteSocketAddress()
+ {
+ return null;
+ }
+
protected final void shutdownInput()
{
if (LOG.isDebugEnabled())
@@ -470,8 +502,8 @@ public String toEndPointString()
return String.format("%s@%h{l=%s,r=%s,%s,fill=%s,flush=%s,to=%d/%d}",
name,
this,
- getLocalAddress(),
- getRemoteAddress(),
+ getLocalSocketAddress(),
+ getRemoteSocketAddress(),
_state.get(),
_fillInterest.toStateString(),
_writeFlusher.toStateString(),
diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ByteArrayEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ByteArrayEndPoint.java
index 9bd94727f721..64b2d7a6a166 100644
--- a/jetty-io/src/main/java/org/eclipse/jetty/io/ByteArrayEndPoint.java
+++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ByteArrayEndPoint.java
@@ -15,10 +15,9 @@
import java.io.EOFException;
import java.io.IOException;
-import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.InetSocketAddress;
-import java.net.UnknownHostException;
+import java.net.SocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.nio.charset.Charset;
@@ -39,29 +38,21 @@
*/
public class ByteArrayEndPoint extends AbstractEndPoint
{
- static final Logger LOG = LoggerFactory.getLogger(ByteArrayEndPoint.class);
- static final InetAddress NOIP;
- static final InetSocketAddress NOIPPORT;
- private static final int MAX_BUFFER_SIZE = Integer.MAX_VALUE - 1024;
-
- static
+ private static SocketAddress noSocketAddress()
{
- InetAddress noip = null;
try
{
- noip = Inet4Address.getByName("0.0.0.0");
- }
- catch (UnknownHostException e)
- {
- LOG.warn("Unable to get IPv4 no-ip reference for 0.0.0.0", e);
+ return new InetSocketAddress(InetAddress.getByName("0.0.0.0"), 0);
}
- finally
+ catch (Throwable x)
{
- NOIP = noip;
- NOIPPORT = new InetSocketAddress(NOIP, 0);
+ throw new RuntimeIOException(x);
}
}
+ private static final Logger LOG = LoggerFactory.getLogger(ByteArrayEndPoint.class);
+ private static final SocketAddress NO_SOCKET_ADDRESS = noSocketAddress();
+ private static final int MAX_BUFFER_SIZE = Integer.MAX_VALUE - 1024;
private static final ByteBuffer EOF = BufferUtil.allocate(0);
private final Runnable _runFillable = () -> getFillInterest().fillable();
@@ -121,6 +112,18 @@ public ByteArrayEndPoint(Scheduler timer, long idleTimeoutMs, ByteBuffer input,
onOpen();
}
+ @Override
+ public SocketAddress getLocalSocketAddress()
+ {
+ return NO_SOCKET_ADDRESS;
+ }
+
+ @Override
+ public SocketAddress getRemoteSocketAddress()
+ {
+ return NO_SOCKET_ADDRESS;
+ }
+
@Override
public void doShutdownOutput()
{
@@ -141,18 +144,6 @@ public void doClose()
}
}
- @Override
- public InetSocketAddress getLocalAddress()
- {
- return NOIPPORT;
- }
-
- @Override
- public InetSocketAddress getRemoteAddress()
- {
- return NOIPPORT;
- }
-
@Override
protected void onIncompleteFlush()
{
diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/EndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/EndPoint.java
index 38b7ecae3b9a..85fc354c735c 100644
--- a/jetty-io/src/main/java/org/eclipse/jetty/io/EndPoint.java
+++ b/jetty-io/src/main/java/org/eclipse/jetty/io/EndPoint.java
@@ -16,6 +16,7 @@
import java.io.Closeable;
import java.io.IOException;
import java.net.InetSocketAddress;
+import java.net.SocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.ReadPendingException;
import java.nio.channels.WritePendingException;
@@ -100,17 +101,39 @@ public interface Wrapper
}
/**
- * @return The local Inet address to which this {@code EndPoint} is bound, or {@code null}
- * if this {@code EndPoint} does not represent a network connection.
+ * @return The local InetSocketAddress to which this {@code EndPoint} is bound, or {@code null}
+ * if this {@code EndPoint} is not bound to a Socket address.
+ * @deprecated use {@link #getLocalSocketAddress()} instead
*/
+ @Deprecated
InetSocketAddress getLocalAddress();
/**
- * @return The remote Inet address to which this {@code EndPoint} is bound, or {@code null}
- * if this {@code EndPoint} does not represent a network connection.
+ * @return the local SocketAddress to which this {@code EndPoint} is bound or {@code null}
+ * if this {@code EndPoint} is not bound to a Socket address.
*/
+ default SocketAddress getLocalSocketAddress()
+ {
+ return getLocalAddress();
+ }
+
+ /**
+ * @return The remote InetSocketAddress to which this {@code EndPoint} is connected, or {@code null}
+ * if this {@code EndPoint} is not connected to a Socket address.
+ * @deprecated use {@link #getRemoteSocketAddress()} instead.
+ */
+ @Deprecated
InetSocketAddress getRemoteAddress();
+ /**
+ * @return The remote SocketAddress to which this {@code EndPoint} is connected, or {@code null}
+ * if this {@code EndPoint} is not connected to a Socket address.
+ */
+ default SocketAddress getRemoteSocketAddress()
+ {
+ return getRemoteAddress();
+ }
+
/**
* @return whether this EndPoint is open
*/
diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/SocketChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/SocketChannelEndPoint.java
index 2dbcb434fd05..1258424ddbb6 100644
--- a/jetty-io/src/main/java/org/eclipse/jetty/io/SocketChannelEndPoint.java
+++ b/jetty-io/src/main/java/org/eclipse/jetty/io/SocketChannelEndPoint.java
@@ -15,8 +15,8 @@
import java.io.Closeable;
import java.io.IOException;
-import java.net.InetSocketAddress;
import java.net.Socket;
+import java.net.SocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.CancelledKeyException;
import java.nio.channels.SelectionKey;
@@ -159,15 +159,29 @@ public SocketChannelEndPoint(SocketChannel channel, ManagedSelector selector, Se
}
@Override
- public InetSocketAddress getLocalAddress()
+ public SocketAddress getLocalSocketAddress()
{
- return (InetSocketAddress)_channel.socket().getLocalSocketAddress();
+ try
+ {
+ return _channel.getLocalAddress();
+ }
+ catch (IOException x)
+ {
+ return null;
+ }
}
@Override
- public InetSocketAddress getRemoteAddress()
+ public SocketAddress getRemoteSocketAddress()
{
- return (InetSocketAddress)_channel.socket().getRemoteSocketAddress();
+ try
+ {
+ return _channel.getRemoteAddress();
+ }
+ catch (IOException e)
+ {
+ return null;
+ }
}
@Override
@@ -185,9 +199,10 @@ protected void doShutdownOutput()
if (!socket.isOutputShutdown())
socket.shutdownOutput();
}
- catch (IOException e)
+ catch (Throwable x)
{
- LOG.debug("Could not shutdown output for {}", _channel, e);
+ if (LOG.isDebugEnabled())
+ LOG.debug("Could not shutdown output for {}", _channel, x);
}
}
diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslClientConnectionFactory.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslClientConnectionFactory.java
index 660c13869e42..bacbac542239 100644
--- a/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslClientConnectionFactory.java
+++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslClientConnectionFactory.java
@@ -15,6 +15,7 @@
import java.io.IOException;
import java.net.InetSocketAddress;
+import java.net.SocketAddress;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Executor;
@@ -100,13 +101,21 @@ public void setRequireCloseMessage(boolean requireCloseMessage)
@Override
public org.eclipse.jetty.io.Connection newConnection(EndPoint endPoint, Map context) throws IOException
{
- InetSocketAddress address = (InetSocketAddress)context.get(ClientConnector.REMOTE_SOCKET_ADDRESS_CONTEXT_KEY);
- String host = address.getHostString();
- int port = address.getPort();
-
- SSLEngine engine = sslContextFactory instanceof SslEngineFactory
- ? ((SslEngineFactory)sslContextFactory).newSslEngine(host, port, context)
- : sslContextFactory.newSSLEngine(host, port);
+ SSLEngine engine;
+ SocketAddress remote = (SocketAddress)context.get(ClientConnector.REMOTE_SOCKET_ADDRESS_CONTEXT_KEY);
+ if (remote instanceof InetSocketAddress)
+ {
+ InetSocketAddress inetRemote = (InetSocketAddress)remote;
+ String host = inetRemote.getHostString();
+ int port = inetRemote.getPort();
+ engine = sslContextFactory instanceof SslEngineFactory
+ ? ((SslEngineFactory)sslContextFactory).newSslEngine(host, port, context)
+ : sslContextFactory.newSSLEngine(host, port);
+ }
+ else
+ {
+ engine = sslContextFactory.newSSLEngine();
+ }
engine.setUseClientMode(true);
context.put(SSL_ENGINE_CONTEXT_KEY, engine);
@@ -176,20 +185,23 @@ public void handshakeSucceeded(Event event) throws SSLException
HostnameVerifier verifier = sslContextFactory.getHostnameVerifier();
if (verifier != null)
{
- InetSocketAddress address = (InetSocketAddress)context.get(ClientConnector.REMOTE_SOCKET_ADDRESS_CONTEXT_KEY);
- String host = address.getHostString();
- try
- {
- if (!verifier.verify(host, event.getSSLEngine().getSession()))
- throw new SSLPeerUnverifiedException("Host name verification failed for host: " + host);
- }
- catch (SSLException x)
- {
- throw x;
- }
- catch (Throwable x)
+ SocketAddress address = (SocketAddress)context.get(ClientConnector.REMOTE_SOCKET_ADDRESS_CONTEXT_KEY);
+ if (address instanceof InetSocketAddress)
{
- throw (SSLException)new SSLPeerUnverifiedException("Host name verification failed for host: " + host).initCause(x);
+ String host = ((InetSocketAddress)address).getHostString();
+ try
+ {
+ if (!verifier.verify(host, event.getSSLEngine().getSession()))
+ throw new SSLPeerUnverifiedException("Host name verification failed for host: " + host);
+ }
+ catch (SSLException x)
+ {
+ throw x;
+ }
+ catch (Throwable x)
+ {
+ throw (SSLException)new SSLPeerUnverifiedException("Host name verification failed for host: " + host).initCause(x);
+ }
}
}
}
diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java
index 24bc59c19b4e..ea896ee7f1ee 100644
--- a/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java
+++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java
@@ -14,7 +14,7 @@
package org.eclipse.jetty.io.ssl;
import java.io.IOException;
-import java.net.InetSocketAddress;
+import java.net.SocketAddress;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
@@ -503,15 +503,15 @@ public boolean isOpen()
}
@Override
- public InetSocketAddress getLocalAddress()
+ public SocketAddress getLocalSocketAddress()
{
- return getEndPoint().getLocalAddress();
+ return getEndPoint().getLocalSocketAddress();
}
@Override
- public InetSocketAddress getRemoteAddress()
+ public SocketAddress getRemoteSocketAddress()
{
- return getEndPoint().getRemoteAddress();
+ return getEndPoint().getRemoteSocketAddress();
}
@Override
diff --git a/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/ProxyConnection.java b/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/ProxyConnection.java
index 452fd80cf6c6..bab2257ad990 100644
--- a/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/ProxyConnection.java
+++ b/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/ProxyConnection.java
@@ -79,11 +79,11 @@ protected void close(Throwable failure)
@Override
public String toConnectionString()
{
- return String.format("%s@%x[l:%d<=>r:%d]",
+ return String.format("%s@%x[l:%s<=>r:%s]",
getClass().getSimpleName(),
hashCode(),
- getEndPoint().getLocalAddress().getPort(),
- getEndPoint().getRemoteAddress().getPort());
+ getEndPoint().getLocalSocketAddress(),
+ getEndPoint().getRemoteSocketAddress());
}
private class ProxyIteratingCallback extends IteratingCallback
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/CustomRequestLog.java b/jetty-server/src/main/java/org/eclipse/jetty/server/CustomRequestLog.java
index 5f69960bdd07..c0e0de3bf40b 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/CustomRequestLog.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/CustomRequestLog.java
@@ -16,6 +16,7 @@
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
+import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -955,13 +956,15 @@ private static void logClientHost(StringBuilder b, Request request, Response res
@SuppressWarnings("unused")
private static void logLocalHost(StringBuilder b, Request request, Response response)
{
- append(b, request.getHttpChannel().getEndPoint().getLocalAddress().getAddress().getHostAddress());
+ InetSocketAddress local = request.getHttpChannel().getLocalAddress();
+ append(b, local == null ? null : local.getAddress().getHostAddress());
}
@SuppressWarnings("unused")
private static void logRemoteHost(StringBuilder b, Request request, Response response)
{
- append(b, request.getHttpChannel().getEndPoint().getRemoteAddress().getAddress().getHostAddress());
+ InetSocketAddress remote = request.getHttpChannel().getRemoteAddress();
+ append(b, remote == null ? null : remote.getAddress().getHostAddress());
}
@SuppressWarnings("unused")
@@ -979,13 +982,15 @@ private static void logClientPort(StringBuilder b, Request request, Response res
@SuppressWarnings("unused")
private static void logLocalPort(StringBuilder b, Request request, Response response)
{
- b.append(request.getHttpChannel().getEndPoint().getLocalAddress().getPort());
+ InetSocketAddress local = request.getHttpChannel().getLocalAddress();
+ append(b, local == null ? null : String.valueOf(local.getPort()));
}
@SuppressWarnings("unused")
private static void logRemotePort(StringBuilder b, Request request, Response response)
{
- b.append(request.getHttpChannel().getEndPoint().getRemoteAddress().getPort());
+ InetSocketAddress remote = request.getHttpChannel().getRemoteAddress();
+ append(b, remote == null ? null : String.valueOf(remote.getPort()));
}
@SuppressWarnings("unused")
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java
index cdd0d5809292..eb015037b483 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java
@@ -15,6 +15,7 @@
import java.io.IOException;
import java.net.InetSocketAddress;
+import java.net.SocketAddress;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.EventListener;
@@ -183,7 +184,7 @@ public HttpChannelState getState()
* {@link TransientListeners} as an {@link AbstractConnector}
* provided listener
* Transient listeners are removed after every request cycle
- * @param listener
+ * @param listener the listener to add
* @return true if the listener was added.
*/
@Deprecated
@@ -313,12 +314,18 @@ public EndPoint getEndPoint()
public InetSocketAddress getLocalAddress()
{
- return _endPoint.getLocalAddress();
+ SocketAddress local = _endPoint.getLocalSocketAddress();
+ if (local instanceof InetSocketAddress)
+ return (InetSocketAddress)local;
+ return null;
}
public InetSocketAddress getRemoteAddress()
{
- return _endPoint.getRemoteAddress();
+ SocketAddress remote = _endPoint.getRemoteSocketAddress();
+ if (remote instanceof InetSocketAddress)
+ return (InetSocketAddress)remote;
+ return null;
}
/**
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ProxyConnectionFactory.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ProxyConnectionFactory.java
index 004104f41c25..b84e2fad1566 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/ProxyConnectionFactory.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ProxyConnectionFactory.java
@@ -18,6 +18,7 @@
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.InetSocketAddress;
+import java.net.SocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.ReadPendingException;
import java.nio.channels.WritePendingException;
@@ -335,21 +336,23 @@ private void upgrade()
String dstPort = _fields[5];
// If UNKNOWN, we must ignore the information sent, so use the EndPoint's.
boolean unknown = "UNKNOWN".equalsIgnoreCase(_fields[1]);
+ EndPoint proxyEndPoint;
if (unknown)
{
- srcIP = getEndPoint().getRemoteAddress().getAddress().getHostAddress();
- srcPort = String.valueOf(getEndPoint().getRemoteAddress().getPort());
- dstIP = getEndPoint().getLocalAddress().getAddress().getHostAddress();
- dstPort = String.valueOf(getEndPoint().getLocalAddress().getPort());
+ EndPoint endPoint = getEndPoint();
+ proxyEndPoint = new ProxyEndPoint(endPoint, endPoint.getLocalSocketAddress(), endPoint.getRemoteSocketAddress());
+ }
+ else
+ {
+ SocketAddress remote = new InetSocketAddress(srcIP, Integer.parseInt(srcPort));
+ SocketAddress local = new InetSocketAddress(dstIP, Integer.parseInt(dstPort));
+ proxyEndPoint = new ProxyEndPoint(getEndPoint(), local, remote);
}
- InetSocketAddress remote = new InetSocketAddress(srcIP, Integer.parseInt(srcPort));
- InetSocketAddress local = new InetSocketAddress(dstIP, Integer.parseInt(dstPort));
if (LOG.isDebugEnabled())
- LOG.debug("Proxy v1 next protocol '{}' for {} r={} l={}", _next, getEndPoint(), remote, local);
+ LOG.debug("Proxy v1 next protocol '{}' for {} -> {}", _next, getEndPoint(), proxyEndPoint);
- EndPoint endPoint = new ProxyEndPoint(getEndPoint(), remote, local);
- upgradeToConnectionFactory(_next, _connector, endPoint);
+ upgradeToConnectionFactory(_next, _connector, proxyEndPoint);
}
}
}
@@ -565,49 +568,49 @@ private void parseBodyAndUpgrade() throws IOException
LOG.debug("Proxy v2 body {} from {} for {}", _next, BufferUtil.toHexSummary(_buffer), this);
// Do we need to wrap the endpoint?
+ ProxyEndPoint proxyEndPoint;
EndPoint endPoint = getEndPoint();
- if (!_local)
+ if (_local)
{
- InetAddress src;
- InetAddress dst;
- int sp;
- int dp;
-
+ _buffer.position(_buffer.position() + _length);
+ proxyEndPoint = new ProxyEndPoint(endPoint, endPoint.getLocalSocketAddress(), endPoint.getRemoteSocketAddress());
+ }
+ else
+ {
+ SocketAddress local;
+ SocketAddress remote;
switch (_family)
{
case INET:
{
byte[] addr = new byte[4];
_buffer.get(addr);
- src = Inet4Address.getByAddress(addr);
+ InetAddress src = Inet4Address.getByAddress(addr);
_buffer.get(addr);
- dst = Inet4Address.getByAddress(addr);
- sp = _buffer.getChar();
- dp = _buffer.getChar();
+ InetAddress dst = Inet4Address.getByAddress(addr);
+ int sp = _buffer.getChar();
+ int dp = _buffer.getChar();
+ local = new InetSocketAddress(dst, dp);
+ remote = new InetSocketAddress(src, sp);
break;
}
-
case INET6:
{
byte[] addr = new byte[16];
_buffer.get(addr);
- src = Inet6Address.getByAddress(addr);
+ InetAddress src = Inet6Address.getByAddress(addr);
_buffer.get(addr);
- dst = Inet6Address.getByAddress(addr);
- sp = _buffer.getChar();
- dp = _buffer.getChar();
+ InetAddress dst = Inet6Address.getByAddress(addr);
+ int sp = _buffer.getChar();
+ int dp = _buffer.getChar();
+ local = new InetSocketAddress(dst, dp);
+ remote = new InetSocketAddress(src, sp);
break;
}
-
default:
throw new IllegalStateException();
}
-
- // Extract Addresses
- InetSocketAddress remote = new InetSocketAddress(src, sp);
- InetSocketAddress local = new InetSocketAddress(dst, dp);
- ProxyEndPoint proxyEndPoint = new ProxyEndPoint(endPoint, remote, local);
- endPoint = proxyEndPoint;
+ proxyEndPoint = new ProxyEndPoint(endPoint, local, remote);
// Any additional info?
while (_buffer.remaining() > nonProxyRemaining)
@@ -648,16 +651,12 @@ private void parseBodyAndUpgrade() throws IOException
}
if (LOG.isDebugEnabled())
- LOG.debug("Proxy v2 {} {}", getEndPoint(), proxyEndPoint.toString());
- }
- else
- {
- _buffer.position(_buffer.position() + _length);
+ LOG.debug("Proxy v2 {} {}", endPoint, proxyEndPoint);
}
if (LOG.isDebugEnabled())
LOG.debug("Proxy v2 parsing dynamic packet part is now done, upgrading to {}", _nextProtocol);
- upgradeToConnectionFactory(_next, _connector, endPoint);
+ upgradeToConnectionFactory(_next, _connector, proxyEndPoint);
}
private void parseHeader() throws IOException
@@ -751,15 +750,21 @@ public static class ProxyEndPoint extends AttributesMap implements EndPoint, End
private static final int PP2_SUBTYPE_SSL_VERSION = 0x21;
private final EndPoint _endPoint;
- private final InetSocketAddress _remote;
- private final InetSocketAddress _local;
+ private final SocketAddress _local;
+ private final SocketAddress _remote;
private Map _tlvs;
+ @Deprecated
public ProxyEndPoint(EndPoint endPoint, InetSocketAddress remote, InetSocketAddress local)
+ {
+ this(endPoint, (SocketAddress)local, remote);
+ }
+
+ public ProxyEndPoint(EndPoint endPoint, SocketAddress local, SocketAddress remote)
{
_endPoint = endPoint;
- _remote = remote;
_local = local;
+ _remote = remote;
}
public EndPoint unwrap()
@@ -847,12 +852,30 @@ public void setIdleTimeout(long idleTimeout)
@Override
public InetSocketAddress getLocalAddress()
+ {
+ SocketAddress local = getLocalSocketAddress();
+ if (local instanceof InetSocketAddress)
+ return (InetSocketAddress)local;
+ return null;
+ }
+
+ @Override
+ public SocketAddress getLocalSocketAddress()
{
return _local;
}
@Override
public InetSocketAddress getRemoteAddress()
+ {
+ SocketAddress remote = getRemoteSocketAddress();
+ if (remote instanceof InetSocketAddress)
+ return (InetSocketAddress)remote;
+ return null;
+ }
+
+ @Override
+ public SocketAddress getRemoteSocketAddress()
{
return _remote;
}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ProxyCustomizer.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ProxyCustomizer.java
index defe8ea6ebbe..415a4104fe37 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/ProxyCustomizer.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ProxyCustomizer.java
@@ -14,6 +14,7 @@
package org.eclipse.jetty.server;
import java.net.InetSocketAddress;
+import java.net.SocketAddress;
import java.util.HashSet;
import java.util.Set;
@@ -54,7 +55,7 @@ public void customize(Connector connector, HttpConfiguration channelConfig, Requ
if (endPoint instanceof ProxyConnectionFactory.ProxyEndPoint)
{
EndPoint underlyingEndpoint = ((ProxyConnectionFactory.ProxyEndPoint)endPoint).unwrap();
- request.setAttributes(new ProxyAttributes(underlyingEndpoint.getRemoteAddress(), underlyingEndpoint.getLocalAddress(), request.getAttributes()));
+ request.setAttributes(new ProxyAttributes(underlyingEndpoint.getLocalSocketAddress(), underlyingEndpoint.getRemoteSocketAddress(), request.getAttributes()));
}
}
@@ -65,13 +66,15 @@ private static class ProxyAttributes extends Attributes.Wrapper
private final int _remotePort;
private final int _localPort;
- private ProxyAttributes(InetSocketAddress remoteAddress, InetSocketAddress localAddress, Attributes attributes)
+ private ProxyAttributes(SocketAddress local, SocketAddress remote, Attributes attributes)
{
super(attributes);
- _remoteAddress = remoteAddress.getAddress().getHostAddress();
- _localAddress = localAddress.getAddress().getHostAddress();
- _remotePort = remoteAddress.getPort();
- _localPort = localAddress.getPort();
+ InetSocketAddress inetLocal = local instanceof InetSocketAddress ? (InetSocketAddress)local : null;
+ InetSocketAddress inetRemote = remote instanceof InetSocketAddress ? (InetSocketAddress)remote : null;
+ _localAddress = inetLocal == null ? null : inetLocal.getAddress().getHostAddress();
+ _remoteAddress = inetRemote == null ? null : inetRemote.getAddress().getHostAddress();
+ _localPort = inetLocal == null ? 0 : inetLocal.getPort();
+ _remotePort = inetRemote == null ? 0 : inetRemote.getPort();
}
@Override
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/SslConnectionFactory.java b/jetty-server/src/main/java/org/eclipse/jetty/server/SslConnectionFactory.java
index e97d82f442b6..f73ce1f087a6 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/SslConnectionFactory.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/SslConnectionFactory.java
@@ -13,6 +13,8 @@
package org.eclipse.jetty.server;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
import java.nio.ByteBuffer;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLSession;
@@ -142,7 +144,10 @@ public Detection detect(ByteBuffer buffer)
@Override
public Connection newConnection(Connector connector, EndPoint endPoint)
{
- SSLEngine engine = _sslContextFactory.newSSLEngine(endPoint.getRemoteAddress());
+ SocketAddress remoteSocketAddress = endPoint.getRemoteSocketAddress();
+ SSLEngine engine = remoteSocketAddress instanceof InetSocketAddress
+ ? _sslContextFactory.newSSLEngine((InetSocketAddress)remoteSocketAddress)
+ : _sslContextFactory.newSSLEngine();
engine.setUseClientMode(false);
SslConnection sslConnection = newSslConnection(connector, endPoint, engine);
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/InetAccessHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/InetAccessHandler.java
index 82c58aa90e93..164e76a48166 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/InetAccessHandler.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/InetAccessHandler.java
@@ -22,15 +22,12 @@
import jakarta.servlet.http.HttpServletResponse;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.http.pathmap.PathSpec;
-import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.server.HttpChannel;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.util.IncludeExcludeSet;
import org.eclipse.jetty.util.InetAddressPattern;
import org.eclipse.jetty.util.InetAddressSet;
import org.eclipse.jetty.util.component.DumpableCollection;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import static org.eclipse.jetty.server.handler.InetAccessSet.AccessTuple;
import static org.eclipse.jetty.server.handler.InetAccessSet.PatternTuple;
@@ -46,8 +43,6 @@
*/
public class InetAccessHandler extends HandlerWrapper
{
- private static final Logger LOG = LoggerFactory.getLogger(InetAccessHandler.class);
-
private final IncludeExcludeSet _set = new IncludeExcludeSet<>(InetAccessSet.class);
/**
@@ -221,16 +216,12 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques
HttpChannel channel = baseRequest.getHttpChannel();
if (channel != null)
{
- EndPoint endp = channel.getEndPoint();
- if (endp != null)
+ InetSocketAddress address = channel.getRemoteAddress();
+ if (address != null && !isAllowed(address.getAddress(), baseRequest, request))
{
- InetSocketAddress address = endp.getRemoteAddress();
- if (address != null && !isAllowed(address.getAddress(), baseRequest, request))
- {
- response.sendError(HttpStatus.FORBIDDEN_403);
- baseRequest.setHandled(true);
- return;
- }
+ response.sendError(HttpStatus.FORBIDDEN_403);
+ baseRequest.setHandled(true);
+ return;
}
}
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java
index 1ff7bf15a6c2..d2be3323217b 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java
@@ -17,12 +17,10 @@
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.PrintWriter;
-import java.net.Inet4Address;
-import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
+import java.net.SocketAddress;
import java.net.URLEncoder;
-import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collections;
@@ -49,8 +47,8 @@
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.http.MetaData;
import org.eclipse.jetty.http.MimeTypes;
-import org.eclipse.jetty.io.AbstractEndPoint;
import org.eclipse.jetty.io.ByteArrayEndPoint;
+import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.ErrorHandler;
@@ -90,25 +88,6 @@
// @checkstyle-disable-check : AvoidEscapedUnicodeCharactersCheck
public class ResponseTest
{
- static final InetSocketAddress LOCALADDRESS;
-
- static
- {
- InetAddress ip = null;
- try
- {
- ip = Inet4Address.getByName("127.0.0.42");
- }
- catch (UnknownHostException e)
- {
- e.printStackTrace();
- }
- finally
- {
- LOCALADDRESS = new InetSocketAddress(ip, 8888);
- }
- }
-
private Server _server;
private HttpChannel _channel;
private ByteBuffer _content = BufferUtil.allocate(16 * 1024);
@@ -126,15 +105,16 @@ public void init() throws Exception
_server.setHandler(new DumpHandler());
_server.start();
- AbstractEndPoint endp = new ByteArrayEndPoint(scheduler, 5000)
+ SocketAddress local = InetSocketAddress.createUnresolved("myhost", 8888);
+ EndPoint endPoint = new ByteArrayEndPoint(scheduler, 5000)
{
@Override
- public InetSocketAddress getLocalAddress()
+ public SocketAddress getLocalSocketAddress()
{
- return LOCALADDRESS;
+ return local;
}
};
- _channel = new HttpChannel(connector, new HttpConfiguration(), endp, new HttpTransport()
+ _channel = new HttpChannel(connector, new HttpConfiguration(), endPoint, new HttpTransport()
{
private Throwable _channelError;
diff --git a/jetty-unixsocket/jetty-unixsocket-common/src/main/java/org/eclipse/jetty/unixsocket/common/UnixSocketEndPoint.java b/jetty-unixsocket/jetty-unixsocket-common/src/main/java/org/eclipse/jetty/unixsocket/common/UnixSocketEndPoint.java
index 50c9020077fd..e5da05c4fd81 100644
--- a/jetty-unixsocket/jetty-unixsocket-common/src/main/java/org/eclipse/jetty/unixsocket/common/UnixSocketEndPoint.java
+++ b/jetty-unixsocket/jetty-unixsocket-common/src/main/java/org/eclipse/jetty/unixsocket/common/UnixSocketEndPoint.java
@@ -14,7 +14,6 @@
package org.eclipse.jetty.unixsocket.common;
import java.io.IOException;
-import java.net.InetSocketAddress;
import java.nio.channels.SelectionKey;
import jnr.unixsocket.UnixSocketChannel;
@@ -39,18 +38,6 @@ public UnixSocketChannel getChannel()
return (UnixSocketChannel)super.getChannel();
}
- @Override
- public InetSocketAddress getLocalAddress()
- {
- return null;
- }
-
- @Override
- public InetSocketAddress getRemoteAddress()
- {
- return null;
- }
-
@Override
protected void doShutdownOutput()
{
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/SocketAddressResolver.java b/jetty-util/src/main/java/org/eclipse/jetty/util/SocketAddressResolver.java
index e4b0ebfb2128..7836cae57a2c 100644
--- a/jetty-util/src/main/java/org/eclipse/jetty/util/SocketAddressResolver.java
+++ b/jetty-util/src/main/java/org/eclipse/jetty/util/SocketAddressResolver.java
@@ -36,8 +36,8 @@
public interface SocketAddressResolver
{
/**
- * Resolves the given host and port, returning a {@link SocketAddress} through the given {@link Promise}
- * with the default timeout.
+ * Resolves via DNS the given host and port, within the connect timeout,
+ * returning a list of {@link InetSocketAddress} through the given {@link Promise}.
*
* @param host the host to resolve
* @param port the port of the resulting socket address
@@ -46,7 +46,7 @@ public interface SocketAddressResolver
public void resolve(String host, int port, Promise> promise);
/**
- * Creates {@link SocketAddress} instances synchronously in the caller thread.
+ * Creates {@link InetSocketAddress} instances synchronously in the caller thread.
*/
@ManagedObject("The synchronous address resolver")
public static class Sync implements SocketAddressResolver
@@ -77,7 +77,7 @@ public void resolve(String host, int port, Promise> prom
}
/**
- * Creates {@link SocketAddress} instances asynchronously in a different thread.
+ * Creates {@link InetSocketAddress} instances asynchronously in a different thread.
* {@link InetSocketAddress#InetSocketAddress(String, int)} attempts to perform a DNS
* resolution of the host name, and this may block for several seconds.
* This class creates the {@link InetSocketAddress} in a separate thread and provides the result
diff --git a/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketConnection.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketConnection.java
index 927c7a763a1f..dc796cc102a1 100644
--- a/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketConnection.java
+++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketConnection.java
@@ -15,6 +15,7 @@
import java.io.IOException;
import java.net.InetSocketAddress;
+import java.net.SocketAddress;
import java.nio.ByteBuffer;
import java.security.SecureRandom;
import java.util.Objects;
@@ -142,14 +143,40 @@ public Parser getParser()
return parser;
}
+ /**
+ * @return the local InetSocketAddress
+ * @deprecated use {@link #getLocalSocketAddress()} instead
+ */
+ @Deprecated
public InetSocketAddress getLocalAddress()
{
- return getEndPoint().getLocalAddress();
+ SocketAddress local = getLocalSocketAddress();
+ if (local instanceof InetSocketAddress)
+ return (InetSocketAddress)local;
+ return null;
+ }
+
+ public SocketAddress getLocalSocketAddress()
+ {
+ return getEndPoint().getLocalSocketAddress();
}
+ /**
+ * @return the remote InetSocketAddress
+ * @deprecated use {@link #getRemoteSocketAddress()} instead
+ */
+ @Deprecated
public InetSocketAddress getRemoteAddress()
{
- return getEndPoint().getRemoteAddress();
+ SocketAddress remote = getRemoteSocketAddress();
+ if (remote instanceof InetSocketAddress)
+ return (InetSocketAddress)remote;
+ return null;
+ }
+
+ public SocketAddress getRemoteSocketAddress()
+ {
+ return getEndPoint().getRemoteSocketAddress();
}
public boolean isUseInputDirectByteBuffers()
diff --git a/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketCoreSession.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketCoreSession.java
index e7a0290f1d70..d76bdee679da 100644
--- a/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketCoreSession.java
+++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketCoreSession.java
@@ -175,12 +175,12 @@ public void setWriteTimeout(Duration timeout)
public SocketAddress getLocalAddress()
{
- return getConnection().getEndPoint().getLocalAddress();
+ return getConnection().getEndPoint().getLocalSocketAddress();
}
public SocketAddress getRemoteAddress()
{
- return getConnection().getEndPoint().getRemoteAddress();
+ return getConnection().getEndPoint().getRemoteSocketAddress();
}
@Override
diff --git a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/internal/MockEndpoint.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/internal/MockEndpoint.java
index eaba70187e17..784d62a607c9 100644
--- a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/internal/MockEndpoint.java
+++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/internal/MockEndpoint.java
@@ -15,6 +15,7 @@
import java.io.IOException;
import java.net.InetSocketAddress;
+import java.net.SocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.ReadPendingException;
import java.nio.channels.WritePendingException;
@@ -33,12 +34,24 @@ public InetSocketAddress getLocalAddress()
throw new UnsupportedOperationException(NOT_SUPPORTED);
}
+ @Override
+ public SocketAddress getLocalSocketAddress()
+ {
+ throw new UnsupportedOperationException(NOT_SUPPORTED);
+ }
+
@Override
public InetSocketAddress getRemoteAddress()
{
throw new UnsupportedOperationException(NOT_SUPPORTED);
}
+ @Override
+ public SocketAddress getRemoteSocketAddress()
+ {
+ throw new UnsupportedOperationException(NOT_SUPPORTED);
+ }
+
@Override
public boolean isOpen()
{