public Socket newSocket() throws IOException { // zero means 'bind on any available port.' if (isEncryptedChannel()) { if (Config.getOutboundBindAny()) return SSLFactory.getSocket( DatabaseDescriptor.getEncryptionOptions(), endPoint(), DatabaseDescriptor.getSSLStoragePort()); else return SSLFactory.getSocket( DatabaseDescriptor.getEncryptionOptions(), endPoint(), DatabaseDescriptor.getSSLStoragePort(), FBUtilities.getLocalAddress(), 0); } else { if (Config.getOutboundBindAny()) return new Socket(endPoint(), DatabaseDescriptor.getStoragePort()); else return new Socket( endPoint(), DatabaseDescriptor.getStoragePort(), FBUtilities.getLocalAddress(), 0); } }
boolean isEncryptedChannel() { switch (DatabaseDescriptor.getEncryptionOptions().internode_encryption) { case none: return false; // if nothing needs to be encrypted then return immediately. case all: break; case dc: if (snitch .getDatacenter(id) .equals(snitch.getDatacenter(FBUtilities.getBroadcastAddress()))) return false; break; case rack: // for rack then check if the DC's are the same. if (snitch.getRack(id).equals(snitch.getRack(FBUtilities.getBroadcastAddress())) && snitch .getDatacenter(id) .equals(snitch.getDatacenter(FBUtilities.getBroadcastAddress()))) return false; break; } return true; }