List<ClientMapping> getClientMappings() {
if (this.remotingServer == null) {
return Collections.emptyList();
}
final SocketBinding socketBinding = this.remotingServer.getSocketBinding();
final List<ClientMapping> clientMappings = socketBinding.getClientMappings();
if (clientMappings != null && !clientMappings.isEmpty()) {
return clientMappings;
}
// TODO: We use the textual form of IP address as the destination address for now.
// This needs to be configurable (i.e. send either host name or the IP address). But
// since this is a corner case (i.e. absence of any client-mappings for a socket binding),
// this should be OK for now
final String destinationAddress = socketBinding.getAddress().getHostAddress();
final InetAddress clientNetworkAddress;
try {
clientNetworkAddress = InetAddress.getByName("::");
} catch (UnknownHostException e) {
throw new RuntimeException(e);
}
final ClientMapping defaultClientMapping = new ClientMapping(clientNetworkAddress, 0, destinationAddress, socketBinding.getAbsolutePort());
return Collections.singletonList(defaultClientMapping);
}