Use IPv6 for key agreement if IPv4 isn't available.

This commit is contained in:
akwizgran
2020-03-11 16:15:46 +00:00
parent 25e50ceb10
commit 5567982fb4

View File

@@ -329,7 +329,7 @@ class LanTcpPlugin extends TcpPlugin {
@Override @Override
public KeyAgreementListener createKeyAgreementListener(byte[] commitment) { public KeyAgreementListener createKeyAgreementListener(byte[] commitment) {
ServerSocket ss = null; ServerSocket ss = null;
for (InetSocketAddress addr : getLocalSocketAddresses(true)) { for (InetSocketAddress addr : getLocalSocketAddresses()) {
// Don't try to reuse the same port we use for contact connections // Don't try to reuse the same port we use for contact connections
addr = new InetSocketAddress(addr.getAddress(), 0); addr = new InetSocketAddress(addr.getAddress(), 0);
try { try {
@@ -355,6 +355,13 @@ class LanTcpPlugin extends TcpPlugin {
return new LanKeyAgreementListener(descriptor, ss); return new LanKeyAgreementListener(descriptor, ss);
} }
private List<InetSocketAddress> getLocalSocketAddresses() {
List<InetSocketAddress> addrs = new ArrayList<>();
addrs.addAll(getLocalSocketAddresses(true));
addrs.addAll(getLocalSocketAddresses(false));
return addrs;
}
@Override @Override
public DuplexTransportConnection createKeyAgreementConnection( public DuplexTransportConnection createKeyAgreementConnection(
byte[] commitment, BdfList descriptor) { byte[] commitment, BdfList descriptor) {