protected void registerListener(ListenerService listener) { listeners.add(listener); if (!listener.isSecure()) { SocketBinding binding = listener.getBinding().getValue(); SocketBinding redirectBinding = listener.getRedirectSocket().getOptionalValue(); if (redirectBinding!=null) { securePortMappings.put(binding.getAbsolutePort(), redirectBinding.getAbsolutePort()); }else{ securePortMappings.put(binding.getAbsolutePort(), -1); } } }
protected void unregisterListener(ListenerService listener) { listeners.remove(listener); if (!listener.isSecure()) { SocketBinding binding = listener.getBinding().getValue(); securePortMappings.remove(binding.getAbsolutePort()); } }
@Override public int getPort(final String protocol, final boolean secure) { Map<String, UndertowListener> listeners = getListenerMap(); UndertowListener listener = null; for (String p : listeners.keySet()) { if (protocol.toLowerCase().contains(p)) { listener = listeners.get(p); } } if (listener != null && listener.getProtocol() == HttpListenerService.PROTOCOL && secure) { if (listeners.containsKey(HttpsListenerService.PROTOCOL)) { listener = listeners.get(HttpsListenerService.PROTOCOL); } else { UndertowLogger.ROOT_LOGGER.secureListenerNotAvailableForPort(protocol); } } if (listener != null) { SocketBinding binding = listener.getSocketBinding(); return binding.getAbsolutePort(); } throw UndertowLogger.ROOT_LOGGER.noPortListeningForProtocol(protocol); }
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 int getPort() { return this.listener.getSocketBinding().getAbsolutePort(); }
protected void registerListener(ListenerService listener) { listeners.add(listener); if (!listener.isSecure()) { SocketBinding binding = listener.getBinding().getValue(); SocketBinding redirectBinding = listener.getRedirectSocket().getOptionalValue(); if (redirectBinding!=null) { securePortMappings.put(binding.getAbsolutePort(), redirectBinding.getAbsolutePort()); }else{ securePortMappings.put(binding.getAbsolutePort(), -1); } } }
protected void registerListener(ListenerService listener) { listeners.add(listener); if (!listener.isSecure()) { SocketBinding binding = listener.getBinding().getValue(); SocketBinding redirectBinding = listener.getRedirectSocket().getOptionalValue(); if (redirectBinding!=null) { securePortMappings.put(binding.getAbsolutePort(), redirectBinding.getAbsolutePort()); }else{ securePortMappings.put(binding.getAbsolutePort(), -1); } } }
@Override public void unadvertise(String name, SocketBinding binding) { this.advertiser.unadvertise(name, binding.getAddress().getHostAddress(), binding.getAbsolutePort() ); }
protected void unregisterListener(ListenerService listener) { listeners.remove(listener); if (!listener.isSecure()) { SocketBinding binding = listener.getBinding().getValue(); securePortMappings.remove(binding.getAbsolutePort()); } }
protected void unregisterListener(ListenerService listener) { listeners.remove(listener); if (!listener.isSecure()) { SocketBinding binding = listener.getBinding().getValue(); securePortMappings.remove(binding.getAbsolutePort()); } }
@Override public void advertise(String name, SocketBinding binding, String...tags) { Registration registration = new Registration("consul", name, binding.getAddress().getHostAddress(), binding.getAbsolutePort(), tags ); this.advertiser.advertise(registration); }
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); }
@Override public int getPort(final String protocol, final boolean secure) { Map<String, UndertowListener> listeners = getListenerMap(); UndertowListener listener = null; for (String p : listeners.keySet()) { if (protocol.toLowerCase().contains(p)) { listener = listeners.get(p); } } if (listener != null && listener.getProtocol() == HttpListenerService.PROTOCOL && secure) { if (listeners.containsKey(HttpsListenerService.PROTOCOL)) { listener = listeners.get(HttpsListenerService.PROTOCOL); } else { UndertowLogger.ROOT_LOGGER.secureListenerNotAvailableForPort(protocol); } } if (listener != null) { SocketBinding binding = listener.getSocketBinding(); return binding.getAbsolutePort(); } throw UndertowLogger.ROOT_LOGGER.noPortListeningForProtocol(protocol); }
public synchronized void advertise(String name, SocketBinding binding, String... tags) throws Exception { Registration registration = new Registration(sourceKey(this.node), name, binding.getAddress().getHostAddress(), binding.getAbsolutePort(), tags); this.registrations.put(name + ":" + binding.getName(), registration); advertise(registration); }
public synchronized void advertise(String name, SocketBinding binding, String... tags) { Registration registration = new Registration(sourceKey(this.node), name, binding.getAddress().getHostAddress(), binding.getAbsolutePort(), tags); this.registrations.put(name + ":" + binding.getName(), registration); advertise(registration); }
@Override public int getPort(final String protocol, final boolean secure) { Map<String, UndertowListener> listeners = getListenerMap(); UndertowListener listener = null; for (String p : listeners.keySet()) { if (protocol.toLowerCase().contains(p)) { listener = listeners.get(p); } } if (listener != null && listener.getProtocol() == HttpListenerService.PROTOCOL && secure) { if (listeners.containsKey(HttpsListenerService.PROTOCOL)) { listener = listeners.get(HttpsListenerService.PROTOCOL); } else { UndertowLogger.ROOT_LOGGER.secureListenerNotAvailableForPort(protocol); } } if (listener != null) { SocketBinding binding = listener.getSocketBinding(); return binding.getAbsolutePort(); } throw UndertowLogger.ROOT_LOGGER.noPortListeningForProtocol(protocol); }
protected String getBaseUrl() { final String address = injectedSocketBinding.getValue().getAddress().getHostAddress(); final int port = injectedSocketBinding.getValue().getAbsolutePort(); if (injectedSocketBinding.getValue().getAddress() instanceof Inet4Address) { return "http://" + address + ":" + port; } else { return "http://[" + address + "]:" + port; } }
String connectorPort = String.valueOf(connectorSocketBindingValue.getAbsolutePort()); if (connectorAddress.equals("0.0.0.0") || connectorAddress.equals("::/128")) { connectorAddress = InetAddress.getLocalHost().getCanonicalHostName();
@Override public Integer getVirtualHostPort(String hostname, boolean securePort) { ServerHostInfo hostInfo = new ServerHostInfo(hostname); Host undertowHost = getUndertowHost(hostInfo); if (undertowHost != null && !undertowHost.getServer().getListeners().isEmpty()) { for(UndertowListener listener : undertowHost.getServer().getListeners()) { if (listener.isSecure() == securePort) { return listener.getSocketBinding().getAbsolutePort(); } } } return null; }
@Override public Integer getVirtualHostPort(String hostname, boolean securePort) { ServerHostInfo hostInfo = new ServerHostInfo(hostname); Host undertowHost = getUndertowHost(hostInfo); if (undertowHost != null && !undertowHost.getServer().getListeners().isEmpty()) { for(UndertowListener listener : undertowHost.getServer().getListeners()) { if (listener.isSecure() == securePort) { return listener.getSocketBinding().getAbsolutePort(); } } } return null; }