io.netty.channel.socket.SocketChannel.remoteAddress()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(201)

本文整理了Java中io.netty.channel.socket.SocketChannel.remoteAddress()方法的一些代码示例,展示了SocketChannel.remoteAddress()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SocketChannel.remoteAddress()方法的具体详情如下:
包路径:io.netty.channel.socket.SocketChannel
类名称:SocketChannel
方法名:remoteAddress

SocketChannel.remoteAddress介绍

暂无

代码示例

代码示例来源:origin: apache/drill

@Override
protected CC initRemoteConnection(SocketChannel channel){
 local=channel.localAddress();
 remote=channel.remoteAddress();
 return null;
}

代码示例来源:origin: apache/drill

@Override
protected SC initRemoteConnection(SocketChannel channel) {
 local = channel.localAddress();
 remote = channel.remoteAddress();
 return null;
}

代码示例来源:origin: andsel/moquette

private ChannelHandler createSslHandler(SocketChannel channel, SslContext sslContext, boolean needsClientAuth) {
    SSLEngine sslEngine = sslContext.newEngine(
        channel.alloc(),
        channel.remoteAddress().getHostString(),
        channel.remoteAddress().getPort());
    sslEngine.setUseClientMode(false);
    if (needsClientAuth) {
      sslEngine.setNeedClientAuth(true);
    }
    return new SslHandler(sslEngine);
  }
}

代码示例来源:origin: apache/geode

@Override
 public void initChannel(SocketChannel ch) throws Exception {
  if (logger.fineEnabled())
   logger.fine("GeodeRedisServer-Connection established with " + ch.remoteAddress());
  ChannelPipeline p = ch.pipeline();
  p.addLast(ByteToCommandDecoder.class.getSimpleName(), new ByteToCommandDecoder());
  p.addLast(ExecutionHandlerContext.class.getSimpleName(),
    new ExecutionHandlerContext(ch, cache, regionCache, GeodeRedisServer.this, pwdB));
 }
}).option(ChannelOption.SO_REUSEADDR, true).option(ChannelOption.SO_RCVBUF, getBufferSize())

代码示例来源:origin: kaaproject/kaa

@Override
protected void initChannel(SocketChannel ch) throws Exception {
 final ChannelPipeline p = ch.pipeline();
 final UUID uuid = UUID.randomUUID();
 LOG.debug("KaaTcpServerInitializer Initializing Channel {} connection from {}:{}",
     uuid, ch.remoteAddress().getAddress().toString(), ch.remoteAddress().getPort());
 Attribute<UUID> uuidAttr = ch.attr(AbstractNettyServer.UUID_KEY);
 uuidAttr.set(uuid);
 p.addLast("binaryDecoder", new ByteArrayDecoder());
 p.addLast("kaaTcpDecoder", getDecoder());
 p.addLast("binaryEncoder", new ByteArrayEncoder());
 p.addLast("kaaTcpEncoder", new KaaTcpEncoder());
 p.addLast("mainHandler", getMainHandler(uuid));
 p.addLast("kaaTcpExceptionHandler", new KaaTcpExceptionHandler());
}

代码示例来源:origin: kaaproject/kaa

@Override
protected void initChannel(SocketChannel ch) throws Exception {
 final ChannelPipeline p = ch.pipeline();
 final UUID uuid = UUID.randomUUID();
 LOG.info("DefaultServerInitializer Initializing Channel {} connection from {}:{}", uuid,
   ch.remoteAddress().getAddress().toString(), ch.remoteAddress().getPort());
 Attribute<UUID> uuidAttr = ch.attr(AbstractNettyServer.UUID_KEY);
 uuidAttr.set(uuid);
 p.addLast("httpDecoder", new HttpRequestDecoder());
 p.addLast("httpAggregator", new HttpObjectAggregator(getClientMaxBodySize()));
 p.addLast("httpDecoderAux", getRequestDecoder());
 p.addLast("httpEncoder", new HttpResponseEncoder());
 p.addLast("httpEncoderAux", new ResponseEncoder());
 p.addLast("handler", getMainHandler(uuid));
 p.addLast("httpExceptionHandler", new DefaultExceptionHandler());
}

代码示例来源:origin: alipay/sofa-rpc

@Override
  protected void channelRead0(ChannelHandlerContext ctx, HttpMessage msg) throws Exception {
    // If this handler is hit then no upgrade has been attempted and the client is just talking HTTP.
    if (LOGGER.isWarnEnabled()) {
      LOGGER.warn("Directly talking: {} (no upgrade was attempted) from {}", msg.protocolVersion(),
        NetUtil.toSocketAddressString(ch.remoteAddress()));
    }
    ChannelPipeline pipeline = ctx.pipeline();
    ChannelHandlerContext thisCtx = pipeline.context(this);
    // 不需要了
    pipeline.addAfter(bizGroup, thisCtx.name(), "Http1ChannelHandler",
      new Http1ServerChannelHandler(serverHandler));
    pipeline.replace(this, "HttpObjectAggregator",
      new HttpObjectAggregator(maxHttpContentLength));
    // HttpServerUpgradeHandler -> HttpServerCodec ->  HttpObjectAggregator -> Http1ChannelHandler, 
    ctx.fireChannelRead(ReferenceCountUtil.retain(msg));
  }
});

代码示例来源:origin: alipay/sofa-rpc

@Override
  protected void channelRead0(ChannelHandlerContext ctx, HttpMessage msg) throws Exception {
    // If this handler is hit then no upgrade has been attempted and the client is just talking HTTP.
    if (LOGGER.isWarnEnabled()) {
      LOGGER.warn("Directly talking: {} (no upgrade was attempted) from {}", msg.protocolVersion(),
        NetUtil.toSocketAddressString(ch.remoteAddress()));
    }
    ChannelPipeline pipeline = ctx.pipeline();
    ChannelHandlerContext thisCtx = pipeline.context(this);
    // 不需要了
    pipeline.addAfter(bizGroup, thisCtx.name(), "Http1ChannelHandler",
      new Http1ServerChannelHandler(serverHandler));
    pipeline.replace(this, "HttpObjectAggregator",
      new HttpObjectAggregator(maxHttpContentLength));
    // HttpServerUpgradeHandler -> HttpServerCodec ->  HttpObjectAggregator -> Http1ChannelHandler, 
    ctx.fireChannelRead(ReferenceCountUtil.retain(msg));
  }
});

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

@Override
 public int compare(SocketChannel t0, SocketChannel t1) {
  // Should not be null as these are filtered previously in matchingChannels.
  assert t0 != null && t0.remoteAddress() != null;
  assert t1 != null && t1.remoteAddress() != null;
  return t0.remoteAddress().toString().compareTo(t1.remoteAddress().toString());
 }
};

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

@Override
 public boolean apply(SocketChannel input) {
  return input.isOpen()
    && input.remoteAddress() != null
    && addresses.contains(input.remoteAddress());
 }
}));

代码示例来源:origin: rakam-io/rakam

@Override
  protected void initChannel(SocketChannel ch) throws Exception {
    InetSocketAddress addr = ch.remoteAddress();
    SslHandler sslHandler;
    // for some hosts the hostname and port required, jdk ssl throws handshake_failure
    if (addr != null) {
      sslHandler = sslCtx.newHandler(ch.alloc(), addr.getHostName(), addr.getPort());
    } else {
      sslHandler = sslCtx.newHandler(ch.alloc());
    }
    ch.pipeline().addLast(sslHandler)
        .addLast(new HttpClientCodec())
        .addLast(new HttpContentDecompressor())
        .addLast(new HttpObjectAggregator(10048576))
        .addLast(new ProxyChannelInboundHandler());
  }
});

代码示例来源:origin: diennea/herddb

public NettyChannel(String name, io.netty.channel.Channel socket,
    ExecutorService callbackexecutor) {
  this.name = name;
  this.socket = socket;
  this.callbackexecutor = callbackexecutor;
  if (socket instanceof SocketChannel) {
    this.remoteAddress = ((SocketChannel) socket).remoteAddress() + "";
  } else {
    this.remoteAddress = "jvm-local";
  }
}

代码示例来源:origin: dremio/dremio-oss

public UserClientConnectionImpl(SocketChannel channel) {
 super(channel, "user client", false);
 uuid = UUID.randomUUID();
 remote = channel.remoteAddress();
}

代码示例来源:origin: dremio/dremio-oss

public String getName() {
 if (name == null) {
  name = String.format("%s <--> %s (%s)", channel.localAddress(), channel.remoteAddress(), clientName);
 }
 return name;
}

代码示例来源:origin: reactor/reactor-netty

/**
 * Retrieve the connection information from the current connection directly
 * @param c the current channel
 * @return the connection information
 */
static ConnectionInfo newConnectionInfo(Channel c) {
  SocketChannel channel = (SocketChannel) c; 
  InetSocketAddress hostAddress = channel.localAddress();
  InetSocketAddress remoteAddress = channel.remoteAddress();
  String scheme = channel.pipeline().get(SslHandler.class) != null ? "https" : "http";
  return new ConnectionInfo(hostAddress, remoteAddress, scheme);
}

代码示例来源:origin: com.datastax.dse/dse-java-driver-core

@Override
 public int compare(SocketChannel t0, SocketChannel t1) {
  // Should not be null as these are filtered previously in matchingChannels.
  assert t0 != null && t0.remoteAddress() != null;
  assert t1 != null && t1.remoteAddress() != null;
  return t0.remoteAddress().toString().compareTo(t1.remoteAddress().toString());
 }
};

代码示例来源:origin: org.apache.geode/gemfire-core

@Override
 public void initChannel(SocketChannel ch) throws Exception {
  if (logger.fineEnabled())
   logger.fine("GemFireRedisServer-Connection established with " + ch.remoteAddress());
  ChannelPipeline p = ch.pipeline();
  p.addLast(ByteToCommandDecoder.class.getSimpleName(), new ByteToCommandDecoder());
  p.addLast(ExecutionHandlerContext.class.getSimpleName(), new ExecutionHandlerContext(ch, cache, regionCache, GemFireRedisServer.this, pwdB));
 }
})

代码示例来源:origin: com.datastax.dse/dse-java-driver-core

@Override
 public boolean apply(SocketChannel input) {
  return input.isOpen()
    && input.remoteAddress() != null
    && addresses.contains(input.remoteAddress());
 }
}));

代码示例来源:origin: org.neo4j/neo4j-causal-clustering

@Override
protected void initChannel( SocketChannel channel ) throws Exception
{
  HandshakeClient handshakeClient = new HandshakeClient();
  installHandlers( channel, handshakeClient );
  log.info( "Scheduling handshake (and timeout) local %s remote %s", channel.localAddress(), channel.remoteAddress() );
  scheduleHandshake( channel, handshakeClient, handshakeDelay.newTimeout() );
  scheduleTimeout( channel, handshakeClient );
}

代码示例来源:origin: org.neo4j/neo4j-causal-clustering

@Override
public void initChannel( SocketChannel ch ) throws Exception
{
  log.info( "Installing handshake server local %s remote %s", ch.localAddress(), ch.remoteAddress() );
  pipelineBuilderFactory.server( ch, log )
      .addFraming()
      .add( "handshake_server_encoder", new ServerMessageEncoder() )
      .add( "handshake_server_decoder", new ServerMessageDecoder() )
      .add( "handshake_server", createHandshakeServer( ch ) )
      .install();
}

相关文章