static SocketAddress remote(ChannelHandlerContext ctx) { if (ctx.channel() != null && ctx.channel().remoteAddress() != null) { return ctx.channel().remoteAddress(); } return new LocalAddress("unknown"); }
static LocalAddress register( Channel channel, LocalAddress oldLocalAddress, SocketAddress localAddress) { if (oldLocalAddress != null) { throw new ChannelException("already bound"); } if (!(localAddress instanceof LocalAddress)) { throw new ChannelException("unsupported address type: " + StringUtil.simpleClassName(localAddress)); } LocalAddress addr = (LocalAddress) localAddress; if (LocalAddress.ANY.equals(addr)) { addr = new LocalAddress(channel); } Channel boundChannel = boundChannels.putIfAbsent(addr, channel); if (boundChannel != null) { throw new ChannelException("address already in use by: " + boundChannel); } return addr; }
/** * @param socketAddress * type of socket address LocalAddress, or * InetSocketAddress, for others returns unknown * @return Map<port, host > two values - port and host of socket address */ protected static Map.Entry<String, String> getHostName( SocketAddress socketAddress) { if (socketAddress instanceof InetSocketAddress) { InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress; return new AbstractMap.SimpleImmutableEntry<>( Integer.toString(inetSocketAddress.getPort()), inetSocketAddress.getHostString()); } else if (socketAddress instanceof LocalAddress) { return new AbstractMap.SimpleImmutableEntry<>(UNKNOWN, ((LocalAddress) socketAddress).id()); } return new AbstractMap.SimpleImmutableEntry<>(UNKNOWN, UNKNOWN); }
localAddress = new LocalAddress(LocalChannel.this);
static LocalAddress register( Channel channel, LocalAddress oldLocalAddress, SocketAddress localAddress) { if (oldLocalAddress != null) { throw new ChannelException("already bound"); } if (!(localAddress instanceof LocalAddress)) { throw new ChannelException("unsupported address type: " + StringUtil.simpleClassName(localAddress)); } LocalAddress addr = (LocalAddress) localAddress; if (LocalAddress.ANY.equals(addr)) { addr = new LocalAddress(channel); } Channel boundChannel = boundChannels.putIfAbsent(addr, channel); if (boundChannel != null) { throw new ChannelException("address already in use by: " + boundChannel); } return addr; }
localAddress = new LocalAddress(LocalChannel.this);
static LocalAddress register( Channel channel, LocalAddress oldLocalAddress, SocketAddress localAddress) { if (oldLocalAddress != null) { throw new ChannelException("already bound"); } if (!(localAddress instanceof LocalAddress)) { throw new ChannelException("unsupported address type: " + StringUtil.simpleClassName(localAddress)); } LocalAddress addr = (LocalAddress) localAddress; if (LocalAddress.ANY.equals(addr)) { addr = new LocalAddress(channel); } Channel boundChannel = boundChannels.putIfAbsent(addr, channel); if (boundChannel != null) { throw new ChannelException("address already in use by: " + boundChannel); } return addr; }
localAddress = new LocalAddress(LocalChannel.this);
static LocalAddress register( Channel channel, LocalAddress oldLocalAddress, SocketAddress localAddress) { if (oldLocalAddress != null) { throw new ChannelException("already bound"); } if (!(localAddress instanceof LocalAddress)) { throw new ChannelException("unsupported address type: " + StringUtil.simpleClassName(localAddress)); } LocalAddress addr = (LocalAddress) localAddress; if (LocalAddress.ANY.equals(addr)) { addr = new LocalAddress(channel); } Channel boundChannel = boundChannels.putIfAbsent(addr, channel); if (boundChannel != null) { throw new ChannelException("address already in use by: " + boundChannel); } return addr; }
@Override public SocketAddress localAddress() { return new LocalAddress("liveoak"); }
static LocalAddress register( Channel channel, LocalAddress oldLocalAddress, SocketAddress localAddress) { if (oldLocalAddress != null) { throw new ChannelException("already bound"); } if (!(localAddress instanceof LocalAddress)) { throw new ChannelException("unsupported address type: " + StringUtil.simpleClassName(localAddress)); } LocalAddress addr = (LocalAddress) localAddress; if (LocalAddress.ANY.equals(addr)) { addr = new LocalAddress(channel); } Channel boundChannel = boundChannels.putIfAbsent(addr, channel); if (boundChannel != null) { throw new ChannelException("address already in use by: " + boundChannel); } return addr; }
public LocalConnector(String address) { this(new LocalAddress(address)); } }
static LocalAddress register( Channel channel, LocalAddress oldLocalAddress, SocketAddress localAddress) { if (oldLocalAddress != null) { throw new ChannelException("already bound"); } if (!(localAddress instanceof LocalAddress)) { throw new ChannelException("unsupported address type: " + StringUtil.simpleClassName(localAddress)); } LocalAddress addr = (LocalAddress) localAddress; if (LocalAddress.ANY.equals(addr)) { addr = new LocalAddress(channel); } Channel boundChannel = boundChannels.putIfAbsent(addr, channel); if (boundChannel != null) { throw new ChannelException("address already in use by: " + boundChannel); } return addr; }
/** * Maps the socketAddress to a "local" address. */ @JsonIgnore public LocalAddress getLocalAddress() { // for local address, we just need "port" to differentiate different addresses. return new LocalAddress("" + port); }
static SocketAddress remote(ChannelHandlerContext ctx) { if (ctx.channel() != null && ctx.channel().remoteAddress() != null) { return ctx.channel().remoteAddress(); } return new LocalAddress("unknown"); }
private void startServerChannels() { String[] hosts = TransportConfiguration.splitHosts(host); for (String h : hosts) { SocketAddress address; if (useInvm) { address = new LocalAddress(h); } else { address = new InetSocketAddress(h, port); } Channel serverChannel = bootstrap.bind(address).syncUninterruptibly().channel(); serverChannelGroup.add(serverChannel); } }
@Override public void start(StartContext context) throws StartException { log.debug("connect client"); try { this.clientInjector.getValue().connect(new LocalAddress("liveoak")); } catch (Exception e) { throw new StartException(e); } }
private void startServerChannels() { String[] hosts = TransportConfiguration.splitHosts(host); for (String h : hosts) { SocketAddress address; if (useInvm) { address = new LocalAddress(h); } else { address = new InetSocketAddress(h, port); } Channel serverChannel = bootstrap.bind(address).syncUninterruptibly().channel(); serverChannelGroup.add(serverChannel); } }
if (LocalServerRegistry.isLocalServer(hostAddress, port, ssl)) { channelType = LocalChannel.class; address = new LocalAddress(hostAddress + ":" + port + ":" + ssl); group = localEventsGroup; } else {
if(params.ssh) { final InetSocketAddress bindingAddress = InetSocketAddress.createUnresolved("0.0.0.0", currentPort); final LocalAddress tcpLocalAddress = new LocalAddress(address.toString());