/** * Adds an HTTP port that listens to the specified {@code localAddress}. * * @param localAddress the local address to bind * * @see #http(int) * @see <a href="#no_port_specified">What happens if no HTTP(S) port is specified?</a> */ public ServerBuilder http(InetSocketAddress localAddress) { return port(new ServerPort(requireNonNull(localAddress, "localAddress"), HTTP)); }
/** * Adds an HTTPS port that listens on all available network interfaces. * * @param port the HTTPS port number. * * @see #https(InetSocketAddress) * @see <a href="#no_port_specified">What happens if no HTTP(S) port is specified?</a> */ public ServerBuilder https(int port) { return port(new ServerPort(port, HTTPS)); }
/** * Adds an HTTPS port that listens to the specified {@code localAddress}. * * @param localAddress the local address to bind * * @see #http(int) * @see <a href="#no_port_specified">What happens if no HTTP(S) port is specified?</a> */ public ServerBuilder https(InetSocketAddress localAddress) { return port(new ServerPort(requireNonNull(localAddress, "localAddress"), HTTPS)); }
/** * Adds an HTTP port that listens on all available network interfaces. * * @param port the HTTP port number. * * @see #http(InetSocketAddress) * @see <a href="#no_port_specified">What happens if no HTTP(S) port is specified?</a> */ public ServerBuilder http(int port) { return port(new ServerPort(port, HTTP)); }
/** * Adds a new {@link ServerPort} that listens to the specified {@code localAddress} using the specified * {@link SessionProtocol}s. Specify multiple protocols to serve more than one protocol on the same port: * * <pre>{@code * ServerBuilder sb = new ServerBuilder(); * // Serve both HTTP and HTTPS at port 8080. * sb.port(new InetSocketAddress(8080), * SessionProtocol.HTTP, * SessionProtocol.HTTPS); * // Enable HTTPS with PROXY protocol support at port 8443. * sb.port(new InetSocketAddress(8443), * SessionProtocol.PROXY, * SessionProtocol.HTTPS); * }</pre> */ public ServerBuilder port(InetSocketAddress localAddress, SessionProtocol... protocols) { return port(new ServerPort(localAddress, protocols)); }
/** * Adds a new {@link ServerPort} that listens to the specified {@code localAddress} using the specified * {@link SessionProtocol}s. Specify multiple protocols to serve more than one protocol on the same port: * * <pre>{@code * ServerBuilder sb = new ServerBuilder(); * // Serve both HTTP and HTTPS at port 8080. * sb.port(new InetSocketAddress(8080), * Arrays.asList(SessionProtocol.HTTP, * SessionProtocol.HTTPS)); * // Enable HTTPS with PROXY protocol support at port 8443. * sb.port(new InetSocketAddress(8443), * Arrays.asList(SessionProtocol.PROXY, * SessionProtocol.HTTPS)); * }</pre> */ public ServerBuilder port(InetSocketAddress localAddress, Iterable<SessionProtocol> protocols) { return port(new ServerPort(localAddress, protocols)); }
/** * Adds a new {@link ServerPort} that listens to the specified {@code port} of all available network * interfaces using the specified {@link SessionProtocol}s. Specify multiple protocols to serve more than * one protocol on the same port: * * <pre>{@code * ServerBuilder sb = new ServerBuilder(); * // Serve both HTTP and HTTPS at port 8080. * sb.port(8080, * Arrays.asList(SessionProtocol.HTTP, * SessionProtocol.HTTPS)); * // Enable HTTPS with PROXY protocol support at port 8443. * sb.port(8443, * Arrays.asList(SessionProtocol.PROXY, * SessionProtocol.HTTPS)); * }</pre> */ public ServerBuilder port(int port, Iterable<SessionProtocol> protocols) { return port(new ServerPort(port, protocols)); }
/** * Adds a new {@link ServerPort} that listens to the specified {@code port} of all available network * interfaces using the specified {@link SessionProtocol}s. Specify multiple protocols to serve more than * one protocol on the same port: * * <pre>{@code * ServerBuilder sb = new ServerBuilder(); * // Serve both HTTP and HTTPS at port 8080. * sb.port(8080, * SessionProtocol.HTTP, * SessionProtocol.HTTPS); * // Enable HTTPS with PROXY protocol support at port 8443. * sb.port(8443, * SessionProtocol.PROXY, * SessionProtocol.HTTPS); * }</pre> */ public ServerBuilder port(int port, SessionProtocol... protocols) { return port(new ServerPort(port, protocols)); }
@Override public void operationComplete(ChannelFuture f) { final Channel ch = f.channel(); assert ch.eventLoop().inEventLoop(); if (f.isSuccess()) { serverChannels.add(ch); ch.closeFuture() .addListener((ChannelFutureListener) future -> serverChannels.remove(future.channel())); final InetSocketAddress localAddress = (InetSocketAddress) ch.localAddress(); final ServerPort actualPort = new ServerPort(localAddress, port.protocols()); // Update the boss thread so its name contains the actual port. Thread.currentThread().setName(bossThreadName(actualPort)); synchronized (activePorts) { // Update the map of active ports. activePorts.put(localAddress, actualPort); } if (logger.isInfoEnabled()) { if (localAddress.getAddress().isAnyLocalAddress() || localAddress.getAddress().isLoopbackAddress()) { port.protocols().forEach(p -> logger.info( "Serving {} at {} - {}://127.0.0.1:{}/", p.name(), localAddress, p.uriText(), localAddress.getPort())); } else { logger.info("Serving {} at {}", Joiner.on('+').join(port.protocols()), localAddress); } } } } }
if (port.localAddress().equals(p.localAddress())) { final ServerPort merged = new ServerPort(port.localAddress(), Sets.union(port.protocols(), p.protocols())); distinctPorts.set(i, merged);
server.port(new ServerPort(port, protocols)); } else { try { final Enumeration<InetAddress> e = NetworkInterface.getByName(iface).getInetAddresses(); while (e.hasMoreElements()) { server.port(new ServerPort(new InetSocketAddress(e.nextElement(), port), protocols)); final byte[] bytes = NetUtil.createByteArrayFromIpAddressString(ip); try { server.port(new ServerPort(new InetSocketAddress( InetAddress.getByAddress(bytes), port), protocols)); } catch (UnknownHostException e) {
server.port(new ServerPort(port, protocols)); } else { try { final Enumeration<InetAddress> e = NetworkInterface.getByName(iface).getInetAddresses(); while (e.hasMoreElements()) { server.port(new ServerPort(new InetSocketAddress(e.nextElement(), port), protocols)); final byte[] bytes = NetUtil.createByteArrayFromIpAddressString(ip); try { server.port(new ServerPort(new InetSocketAddress( InetAddress.getByAddress(bytes), port), protocols)); } catch (UnknownHostException e) {
server.port(new ServerPort(DEFAULT_PORT.getPort(), DEFAULT_PORT.getProtocols())); } else { configurePorts(server, ports);
ports = ImmutableList.of(new ServerPort(0, HTTP)); ports = resolveDistinctPorts(this.ports); } else { ports = ImmutableList.of(new ServerPort(0, HTTPS));
/** * Adds a port that serves the HTTP requests. If unspecified, cleartext HTTP on port 36462 is used. * * @param port the TCP/IP port number * @param protocol {@link SessionProtocol#HTTP} or {@link SessionProtocol#HTTPS} */ public CentralDogmaBuilder port(int port, SessionProtocol protocol) { return port(new ServerPort(port, protocol)); }
/** * Adds a port that serves the HTTP requests. If unspecified, cleartext HTTP on port 36462 is used. * * @param port the TCP/IP port number * @param protocol {@link SessionProtocol#HTTP} or {@link SessionProtocol#HTTPS} */ public CentralDogmaBuilder port(int port, SessionProtocol protocol) { return port(new ServerPort(port, protocol)); }
/** * Adds a port that serves the HTTP requests. If unspecified, cleartext HTTP on port 36462 is used. * * @param port the TCP/IP port number * @param protocol {@link SessionProtocol#HTTP} or {@link SessionProtocol#HTTPS} */ public CentralDogmaBuilder port(int port, SessionProtocol protocol) { return port(new ServerPort(port, protocol)); }
/** * Adds a port that serves the HTTP requests. If unspecified, cleartext HTTP on port 36462 is used. * * @param localAddress the TCP/IP load address to bind * @param protocol {@link SessionProtocol#HTTP} or {@link SessionProtocol#HTTPS} */ public CentralDogmaBuilder port(InetSocketAddress localAddress, SessionProtocol protocol) { return port(new ServerPort(localAddress, protocol)); }
/** * Adds a port that serves the HTTP requests. If unspecified, cleartext HTTP on port 36462 is used. * * @param localAddress the TCP/IP load address to bind * @param protocol {@link SessionProtocol#HTTP} or {@link SessionProtocol#HTTPS} */ public CentralDogmaBuilder port(InetSocketAddress localAddress, SessionProtocol protocol) { return port(new ServerPort(localAddress, protocol)); }
/** * Adds a port that serves the HTTP requests. If unspecified, cleartext HTTP on port 36462 is used. * * @param localAddress the TCP/IP load address to bind * @param protocol {@link SessionProtocol#HTTP} or {@link SessionProtocol#HTTPS} */ public CentralDogmaBuilder port(InetSocketAddress localAddress, SessionProtocol protocol) { return port(new ServerPort(localAddress, protocol)); }