@Override public InetSocketAddress getRemoteAddress() { // Both host and port may not be null in the model, no need to validate here // Don't do resolving here, let mod_cluster deal with it return new InetSocketAddress(binding.getUnresolvedDestinationAddress(), binding.getDestinationPort()); }
@Override public boolean preferred(Node node) { OutboundSocketBinding binding = this.binding.get(); try { return binding.getResolvedDestinationAddress().equals(node.getSocketAddress().getAddress()) && (binding.getDestinationPort() == node.getSocketAddress().getPort()); } catch (UnknownHostException e) { throw new IllegalArgumentException(e); } } }
@Override public InetSocketAddress getLocalAddress() { if (binding.getOptionalSourceAddress() != null) { return new InetSocketAddress(binding.getOptionalSourceAddress(), binding.getAbsoluteSourcePort() == null ? 0 : binding.getAbsoluteSourcePort()); } else if (binding.getAbsoluteSourcePort() != null) { // Bind to port only if source address is not configured return new InetSocketAddress(binding.getAbsoluteSourcePort()); } // No binding configured so don't bind return null; }
port = binding.getDestinationPort(); host = NetworkUtils.canonize(binding.getUnresolvedDestinationAddress()); if (binding.getSourceAddress() != null) { tc.getParams().put(TransportConstants.LOCAL_ADDRESS_PROP_NAME, NetworkUtils.canonize(binding.getSourceAddress().getHostAddress())); if (binding.getSourcePort() != null) { tc.getParams().put(TransportConstants.LOCAL_PORT_PROP_NAME, binding.getAbsoluteSourcePort());
/** * Creates a {@link Socket} represented by this {@link OutboundSocketBinding} and connects to the * destination * * @return * @throws IOException */ public Socket connect() throws IOException { final Socket socket = this.createSocket(); final InetAddress destinationAddress = this.getResolvedDestinationAddress(); final int destinationPort = this.getDestinationPort(); final SocketAddress destination = new InetSocketAddress(destinationAddress, destinationPort); socket.connect(destination); return socket; }
/** * Generates and returns the URI that corresponds to the local outbound connection. * If the URI has already been generated in a previous request, then it returns that back. * Else the URI is constructed out of the outbound socket binding's destination address and destination port. * * @return * @throws IOException * @throws URISyntaxException */ private synchronized URI getConnectionURI() throws IOException, URISyntaxException { if (this.connectionURI != null) { return this.connectionURI; } final OutboundSocketBinding destinationOutboundSocket = this.destinationOutboundSocketBindingInjectedValue.getValue(); final InetAddress destinationAddress = destinationOutboundSocket.getDestinationAddress(); final int port = destinationOutboundSocket.getDestinationPort(); this.connectionURI = new URI(LOCAL_URI_SCHEME + destinationAddress.getHostAddress() + ":" + port); return this.connectionURI; }
@Override public int getPort() { return outboundSocketBinding.getDestinationPort(); } }
/** * Creates a {@link Socket} represented by this {@link OutboundSocketBinding} and connects to the * destination * * @return * @throws IOException */ public Socket connect() throws IOException { final Socket socket = this.createSocket(); final InetAddress destinationAddress = this.getDestinationAddress(); final int destinationPort = this.getDestinationPort(); final SocketAddress destination = new InetSocketAddress(destinationAddress, destinationPort); socket.connect(destination); return socket; }
public static InetAddress outboundSocketBindingGetResolvedDestinationAddress(OutboundSocketBinding serverBinding) throws UnknownHostException { try { return serverBinding.getResolvedDestinationAddress(); } catch (NoSuchMethodError _nsme) { // When using jboss-as we need to use the now deprecated getDestinationAddress return serverBinding.getDestinationAddress(); } }
/** * @deprecated use {@link #getResolvedDestinationAddress()} instead to get the resolved destination address * or {@link #getUnresolvedDestinationAddress()} to get the unresolved destination address. */ @Deprecated public synchronized InetAddress getDestinationAddress() throws UnknownHostException { return getResolvedDestinationAddress(); }
private SocketAddress getOptionalSourceSocketAddress() { final InetAddress sourceAddress = this.getSourceAddress(); final Integer absoluteSourcePort = this.getAbsoluteSourcePort(); if (sourceAddress == null && absoluteSourcePort == null) { return null; } if (sourceAddress == null) { return new InetSocketAddress(absoluteSourcePort); } return new InetSocketAddress(sourceAddress, absoluteSourcePort); }
port = binding.getDestinationPort(); host = NetworkUtils.canonize(binding.getUnresolvedDestinationAddress()); if (binding.getSourceAddress() != null) { tc.getParams().put(TransportConstants.LOCAL_ADDRESS_PROP_NAME, NetworkUtils.canonize(binding.getSourceAddress().getHostAddress())); if (binding.getSourcePort() != null) { tc.getParams().put(TransportConstants.LOCAL_PORT_PROP_NAME, binding.getAbsoluteSourcePort());
/** * Creates a {@link Socket} represented by this {@link OutboundSocketBinding} and connects to the * destination. * * @return the created and connected socket * @throws IOException */ public Socket connect() throws IOException { final Socket socket = this.createSocket(); final InetAddress destinationAddress = this.getResolvedDestinationAddress(); final int destinationPort = this.getDestinationPort(); final SocketAddress destination = new InetSocketAddress(destinationAddress, destinationPort); socket.connect(destination); return socket; }
private InetSocketAddress getServerSocketAddress(ServerConfig server) throws StartException { final String ref = server.getOutgoingSocketBinding(); final OutboundSocketBinding binding = socketBindings.get(ref); if (ref == null) { throw MailMessages.MESSAGES.outboundSocketBindingNotAvailable(ref); } final InetAddress destinationAddress; try { destinationAddress = binding.getDestinationAddress(); } catch (UnknownHostException uhe) { throw MailMessages.MESSAGES.unknownOutboundSocketBindingDestination(uhe, ref); } return new InetSocketAddress(destinationAddress, binding.getDestinationPort()); }
@Override public int getPort() { return outboundSocketBinding.getDestinationPort(); } }
@Override public InetAddress getAddress() { try { return outboundSocketBinding.getResolvedDestinationAddress(); } catch (UnknownHostException e) { throw new UncheckedIOException(e); } }
private SocketAddress getOptionalSourceSocketAddress() { final InetAddress sourceAddress = this.getSourceAddress(); final Integer absoluteSourcePort = this.getAbsoluteSourcePort(); if (sourceAddress == null && absoluteSourcePort == null) { return null; } if (sourceAddress == null) { return new InetSocketAddress(absoluteSourcePort); } return new InetSocketAddress(sourceAddress, absoluteSourcePort); }
private URI getUri() throws URISyntaxException { OutboundSocketBinding binding = socketBinding.getValue(); return new URI(scheme, null, binding.getUnresolvedDestinationAddress(), binding.getDestinationPort(), path, null, null); }
@Override public void accept(P protocol) { if (!this.bindings.isEmpty()) { List<A> initialHosts = new ArrayList<>(this.bindings.size()); for (Supplier<OutboundSocketBinding> bindingValue : this.bindings) { OutboundSocketBinding binding = bindingValue.get(); try { initialHosts.add(this.hostTransformer.apply(new InetSocketAddress(binding.getResolvedDestinationAddress(), binding.getDestinationPort()))); } catch (UnknownHostException e) { throw JGroupsLogger.ROOT_LOGGER.failedToResolveSocketBinding(e, binding); } } // In the absence of some common interface, we need to use reflection PrivilegedAction<Protocol> action = () -> protocol.setValue("initial_hosts", initialHosts); WildFlySecurityManager.doUnchecked(action); } } }
/** * Generates and returns the URI that corresponds to the remote outbound connection. * If the URI has already been generated in a previous request, then it returns that back. * Else the URI is constructed out of the outbound socket binding's destination address and destination port. * * @return * @throws IOException * @throws URISyntaxException */ private synchronized URI getConnectionURI() throws IOException, URISyntaxException { if (this.connectionURI != null) { return this.connectionURI; } final OutboundSocketBinding destinationOutboundSocket = this.destinationOutboundSocketBindingInjectedValue.getValue(); final InetAddress destinationAddress = destinationOutboundSocket.getDestinationAddress(); final int port = destinationOutboundSocket.getDestinationPort(); this.connectionURI = new URI(REMOTE_URI_SCHEME + NetworkUtils.formatPossibleIpv6Address( destinationAddress.getHostAddress()) + ":" + port); return this.connectionURI; }