8338380: Update TLSCommon/interop/AbstractServer to specify an interface to listen for connections
Reviewed-by: rhalade
This commit is contained in:
parent
6041c936d6
commit
0b5c8870e5
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -22,6 +22,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
@ -52,11 +54,21 @@ public abstract class AbstractServer extends AbstractPeer implements Server {
|
|||||||
|
|
||||||
public static abstract class Builder extends AbstractPeer.Builder {
|
public static abstract class Builder extends AbstractPeer.Builder {
|
||||||
|
|
||||||
|
private InetAddress listenInterface = InetAddress.getLoopbackAddress();
|
||||||
private int port;
|
private int port;
|
||||||
|
|
||||||
// Indicates if requires client authentication.
|
// Indicates if requires client authentication.
|
||||||
private boolean clientAuth = true;
|
private boolean clientAuth = true;
|
||||||
|
|
||||||
|
public InetAddress getListenInterface() {
|
||||||
|
return listenInterface;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setListenInterface(InetAddress listenInterface) {
|
||||||
|
this.listenInterface = listenInterface;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public int getPort() {
|
public int getPort() {
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -22,6 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.InetAddress;
|
||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -53,7 +54,8 @@ public class JdkServer extends AbstractServer {
|
|||||||
context = Utilities.createSSLContext(builder.getCertTuple());
|
context = Utilities.createSSLContext(builder.getCertTuple());
|
||||||
SSLServerSocketFactory serverFactory = context.getServerSocketFactory();
|
SSLServerSocketFactory serverFactory = context.getServerSocketFactory();
|
||||||
serverSocket
|
serverSocket
|
||||||
= (SSLServerSocket) serverFactory.createServerSocket(builder.getPort());
|
= (SSLServerSocket) serverFactory.createServerSocket(builder.getPort(),
|
||||||
|
0, builder.getListenInterface());
|
||||||
configServerSocket(builder);
|
configServerSocket(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user