@Override public ClientMapping readObject(ObjectInput input) throws IOException { byte[] sourceAddress = new byte[IndexSerializer.UNSIGNED_BYTE.readInt(input)]; input.readFully(sourceAddress); int sourceNetworkMaskBits = IndexSerializer.UNSIGNED_BYTE.readInt(input); String destAddress = input.readUTF(); int destPort = IndexSerializer.UNSIGNED_SHORT.readInt(input); return new ClientMapping(InetAddress.getByAddress(sourceAddress), sourceNetworkMaskBits, destAddress, destPort); }
List<ClientMapping> getClientMappings() { final List<ClientMapping> ret = new ArrayList<>(); RemotingConnectorBindingInfoService.RemotingConnectorInfo info = this.remotingConnectorInfo.get(); if (info.getSocketBinding().getClientMappings() != null && !info.getSocketBinding().getClientMappings().isEmpty()) { ret.addAll(info.getSocketBinding().getClientMappings()); } else { // 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 = info.getSocketBinding().getAddress().getHostAddress(); final InetAddress clientNetworkAddress; try { clientNetworkAddress = InetAddress.getByName("::"); } catch (UnknownHostException e) { throw new RuntimeException(e); } final ClientMapping defaultClientMapping = new ClientMapping(clientNetworkAddress, 0, destinationAddress, info.getSocketBinding().getAbsolutePort()); ret.add(defaultClientMapping); } return ret; } }
@Override public ClientMapping readObject(ObjectInput input) throws IOException { byte[] sourceAddress = new byte[IndexSerializer.UNSIGNED_BYTE.readInt(input)]; input.readFully(sourceAddress); int sourceNetworkMaskBits = IndexSerializer.UNSIGNED_BYTE.readInt(input); String destAddress = input.readUTF(); int destPort = IndexSerializer.UNSIGNED_SHORT.readInt(input); return new ClientMapping(InetAddress.getByAddress(sourceAddress), sourceNetworkMaskBits, destAddress, destPort); }
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); }
clientMappings.add(new ClientMapping(sourceAddress, mask, destination, port));
clientMappings.add(new ClientMapping(sourceAddress, mask, destination, port));
clientMappings.add(new ClientMapping(sourceAddress, mask, destination, port));
clientMappings.add(new ClientMapping(sourceAddress, mask, destination, port));