GVKun编程网logo

头条搜索Bytespider IP反解析(头条signature反爬)

18

本文将为您提供关于头条搜索BytespiderIP反解析的详细介绍,我们还将为您解释头条signature反爬的相关知识,同时,我们还将为您提供关于com.bumptech.glide.load.re

本文将为您提供关于头条搜索Bytespider IP反解析的详细介绍,我们还将为您解释头条signature反爬的相关知识,同时,我们还将为您提供关于com.bumptech.glide.load.resource.bytes.BytesResource的实例源码、delphi – 我应该如何调整我的代码以实现TBytes和TIdBytes之间的兼容性?、io.netty.handler.codec.bytes.ByteArrayDecoder的实例源码、io.netty.handler.codec.bytes.ByteArrayEncoder的实例源码的实用信息。

本文目录一览:

头条搜索Bytespider IP反解析(头条signature反爬)

头条搜索Bytespider IP反解析(头条signature反爬)

反查IP

站长可以通过DNS反查IP的方式判断某只spider是否来自头条搜索引擎。根据平台不同验证方法不同,如linux/windows/os三种平台下的验证方法分别如下

在linux平台下,您可以使用host ip命令反解ip来判断是否来自Bytespider的抓取。Bytespider的hostname以*.bytedance.com的格式命名,非 *.bytedance.com即为冒充

host 111.225.148.250

148.148.225.111.in-addr.arpa domain name pointer bytespider-111-225-148-148.crawl.bytedance.com.

在windows平台或者IBM OS/2平台下,您可以使用nslookup ip命令反解ip来判断是否来自Bytespider的抓取。打开命令处理器 输入nslookup  -qt=ptr  xxx.xxx.xxx.xxx(IP地 址)就能解析ip,来判断是否来自Bytespider的抓取,Bytespider的hostname以*.bytedance.com 的格式命名,非*.bytedance.com 即为冒充。

在mac os平台下,您可以使用dig命令反解ip来判断是否来自Bytespider的抓取。打开命令处理器输入dig -x xxx.xxx.xxx.xxx(IP地址)就能解析ip, 来判断是否来自Bytespider的抓取,Bytespider的hostname以 *.bytedance.com的格式命名,非 *.bytedance.com即为冒充。

com.bumptech.glide.load.resource.bytes.BytesResource的实例源码

com.bumptech.glide.load.resource.bytes.BytesResource的实例源码

项目:GitHub    文件:BitmapBytesTranscoder.java   
@Override
public Resource<byte[]> transcode(Resource<Bitmap> toTranscode) {
  ByteArrayOutputStream os = new ByteArrayOutputStream();
  toTranscode.get().compress(compressFormat,quality,os);
  toTranscode.recycle();
  return new BytesResource(os.toByteArray());
}
项目:GitHub    文件:BitmapBytesTranscoder.java   
@Override
public Resource<byte[]> transcode(Resource<Bitmap> toTranscode,Options options) {
  ByteArrayOutputStream os = new ByteArrayOutputStream();
  toTranscode.get().compress(compressFormat,os);
  toTranscode.recycle();
  return new BytesResource(os.toByteArray());
}
项目:gallery    文件:StreamByteArrayResourceDecoder.java   
@Override
public Resource<byte[]> decode(InputStream in,int width,int height) throws
        IOException {
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    byte[] buffer = new byte[1024];
    int count;
    while ((count = in.read(buffer)) != -1) {
        bytes.write(buffer,count);
    }
    return new BytesResource(bytes.toByteArray());
}
项目:Moegallery    文件:StreamByteArrayResourceDecoder.java   
@Override
public Resource<byte[]> decode(InputStream in,count);
    }
    return new BytesResource(bytes.toByteArray());
}
项目:saarang-iosched    文件:BitmapBytesTranscoder.java   
@Override
public Resource<byte[]> transcode(Resource<Bitmap> toTranscode) {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    toTranscode.get().compress(compressFormat,os);
    toTranscode.recycle();
    return new BytesResource(os.toByteArray());
}
项目:AppDevFestSudeste2015    文件:BitmapBytesTranscoder.java   
@Override
public Resource<byte[]> transcode(Resource<Bitmap> toTranscode) {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    toTranscode.get().compress(compressFormat,os);
    toTranscode.recycle();
    return new BytesResource(os.toByteArray());
}
项目:devfestnorte-app    文件:BitmapBytesTranscoder.java   
@Override
public Resource<byte[]> transcode(Resource<Bitmap> toTranscode) {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    toTranscode.get().compress(compressFormat,os);
    toTranscode.recycle();
    return new BytesResource(os.toByteArray());
}
项目:GitHub    文件:GifdrawableBytesTranscoder.java   
@Override
public Resource<byte[]> transcode(Resource<Gifdrawable> toTranscode) {
  Gifdrawable gifData = toTranscode.get();
  ByteBuffer byteBuffer = gifData.getBuffer();
  return new BytesResource(ByteBufferUtil.toBytes(byteBuffer));
}
项目:GitHub    文件:GifdrawableBytesTranscoder.java   
@Override
public Resource<byte[]> transcode(Resource<Gifdrawable> toTranscode,Options options) {
  Gifdrawable gifData = toTranscode.get();
  ByteBuffer byteBuffer = gifData.getBuffer();
  return new BytesResource(ByteBufferUtil.toBytes(byteBuffer));
}
项目:GlidePlus    文件:StreamByteArrayResourceDecoder.java   
@Override
public Resource<byte[]> decode(InputStream source,int height) throws IOException {
    return new BytesResource(inputStreamToBytes(source));
}

delphi – 我应该如何调整我的代码以实现TBytes和TIdBytes之间的兼容性?

delphi – 我应该如何调整我的代码以实现TBytes和TIdBytes之间的兼容性?

我遇到了与“ Delphi XE4 Indy compatibility issue between TBytes and TidBytes”中提到的相同的问题,即在使用Delphi XE4进行编译时TBytes(Delphi RTL)和TIdBytes(Indy)数据类型之间的兼容性问题.我的问题的根源是代码不完全符合Indy的接口,并且一些函数在调用本机Indy IO过程时使用TBytes而不是TIdBytes.

所以我想知道最好的解决方案是什么?

我认为有两种方法:

>重构项目中的所有功能以使用TIdBytes而不是TBytes.
>实现TBytesToTidBytes转换过程(将TBytes转换为TIdBytes)并在进行上述本机Indy调用之前调用该过程.

哪种方法更好/最好?您对我如何做到这一点有什么其他想法吗?

仅供参考:我尝试使用XE4配置的项目可在sourceforge上在线获取:http://sourceforge.net/projects/indy10clieservr/?source=directory

建议的转换程序应该是这样的:

procedure TBytesToTIdBytes(const Input:TBytes,var Output: TIdBytes)
var 
    i,L : Integer;
    allocate : Boolean;
begin
    L := Length(Input);
    if(Length(Output) <> L) then 
    begin 
        SetLength(Output,L);
    end;
    if(L > 0) then 
        move(Pointer(Input)^,Pointer(Output)^,L);
end;

解决方法

TBytes和TIdBytes都是作为动态数组实现的,它们只是以不同方式声明. “政治上正确”的解决方案是制作字节的副本.但这会浪费大型阵列的内存.更简单的解决方案是使用类型转换,以便您可以利用数组的内部引用计数,例如:

type
  PIdBytes = ^TIdBytes;
var
  B1: TBytes;
  B2: TIdBytes;
begin
  B1 := ...;
  B2 := PIdBytes(@B1)^;
end;

或者干脆:

var
  B1: TBytes;
  B2: TIdBytes;
begin
  B1 := ...;
  B2 := TIdBytes(B1);
end;

io.netty.handler.codec.bytes.ByteArrayDecoder的实例源码

io.netty.handler.codec.bytes.ByteArrayDecoder的实例源码

项目:JPRE    文件:TestClient.java   
public void start() throws Exception {
    EventLoopGroup group = new NioEventLoopGroup();
    try {
        Bootstrap b = new Bootstrap();
        b.group(group)
                .channel(NioSocketChannel.class)
                .remoteAddress(new InetSocketAddress(this.host,this.port))
                .handler(new ChannelInitializer<SocketChannel>() {
                    @Override
                    protected void initChannel(SocketChannel ch) throws Exception {
                        System.out.println("connected server...");
                        ch.pipeline().addLast(new ByteArrayEncoder());
                        ch.pipeline().addLast(new ByteArrayDecoder());
                        ch.pipeline().addLast(new EchoClientHandler());
                    }
                });

        ChannelFuture cf = b.connect().sync();

        cf.channel().closeFuture().sync();
    } finally {
        group.shutdownGracefully().sync();
    }
}
项目:kaa    文件:AbstractKaaTcpserverInitializer.java   
@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());
}
项目:sds    文件:NettyServerServiceImpl.java   
@Override
public synchronized void start() {
    bossGroup = new NioEventLoopGroup(); // (1)
    workerGroup = new NioEventLoopGroup();
    try {
        b = new ServerBootstrap(); // (2)
        b.group(bossGroup,workerGroup)
                .channel(NioServerSocketChannel.class) // (3)
                .childHandler(new ChannelInitializer<SocketChannel>() { // (4)
                    @Override
                    public void initChannel(SocketChannel ch) throws Exception {

                        ch.pipeline().addLast(new ByteArrayDecoder());
                        ch.pipeline().addLast(new ByteArrayEncoder());

                        ch.pipeline().addLast(new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE,4,4));

                        ch.pipeline().addLast(new IdleStateHandler(heartTime,heartTime,TimeUnit.SECONDS));

                        ch.pipeline().addLast(new DeliveryHandler(deliveryService));

                    }
                })
                .option(ChannelOption.so_BACKLOG,128)          // (5)
                .childOption(ChannelOption.so_KEEPALIVE,true); // (6)

        // Bind and start to accept incoming connections.
        b.bind(settingService.getDeliveryPort());

        logger.info("socket: "+settingService.getDeliveryPort()+" starting....");
        // Wait until the server socket is closed.
        // In this example,this does not happen,but you can do that to gracefully
    } catch (Exception e) {
        e.printstacktrace();
    }
}
项目:Camel    文件:ChannelHandlerFactories.java   
public static ChannelHandlerFactory newByteArrayDecoder(String protocol) {
    if ("udp".equals(protocol)) {
        return new ShareableChannelHandlerFactory(new DatagramPacketByteArrayDecoder());
    } else {
        return new ShareableChannelHandlerFactory(new ByteArrayDecoder());
    }
}
项目:yummy-xml-UI    文件:P2PTunnel.java   
public ChannelInitializerImpl(int command,String message) {
    this.handler_list = new ChannelHandler[]{new CMDFieldPrepender(command),new LengthFieldPrepender(4),//new StringEncoder(CommonConstants.UTF8),new StringDecoder(CommonConstants.UTF8),new StringEncoder(CommonConstants.UTF8),new ByteArrayDecoder(),//new MessageClientHandler(message)};
        new ByteMessageClientHandler(message)};
        //new DelimiterBasedFrameDecoder(2048,Delimiters.lineDelimiter()),}
项目:netty-ssl-example    文件:NettySocketClient.java   
public void open(EventLoopGroup eventLoopGroup) throws Exception {
    if (openned.compareAndSet(false,true)) {
        eventloopGroop = eventLoopGroup == null ? new NioEventLoopGroup()
                : eventLoopGroup;
        Bootstrap bootstrap = new Bootstrap();
        final BlockingByteArrayClientHandler handler = new BlockingByteArrayClientHandler(
                this);
        this.clientHandler = handler;
        bootstrap.group(eventloopGroop).channel(NioSocketChannel.class)
                .handler(new ChannelInitializer<SocketChannel>() {
                    @Override
                    protected void initChannel(SocketChannel ch)
                            throws Exception {
                        ChannelPipeline pipeline = ch.pipeline();
                        SSLEngine engine = SecureSocketSslContextFactory
                                .getClientContext().createSSLEngine();
                        engine.setUseClientMode(true);
                        pipeline.addLast("ssl",new SslHandler(engine));
                        pipeline.addLast("length-decoder",new LengthFieldBasedFrameDecoder(
                                        Integer.MAX_VALUE,4));
                        pipeline.addLast("bytearray-decoder",new ByteArrayDecoder());
                        pipeline.addLast("length-encoder",new LengthFieldPrepender(4));
                        pipeline.addLast("bytearray-encoder",new ByteArrayEncoder());
                        pipeline.addLast("handler",handler);
                    }

                });
        channelFuture = bootstrap.connect(this.remoteHost,this.remotePort)
                .sync();
    }
}
项目:netty-ssl-example    文件:SecureSocketServerLengthFrameInitializer.java   
@Override
public void initChannel(SocketChannel ch) throws Exception {
    ChannelPipeline pipeline = ch.pipeline();
    SSLEngine engine =
        SecureSocketSslContextFactory.getServerContext().createSSLEngine();
    engine.setUseClientMode(false);
    pipeline.addLast("ssl",new SslHandler(engine));  
    pipeline.addLast("length-decoder",new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE,4)); 
    pipeline.addLast("bytearray-decoder",new ByteArrayDecoder());
    pipeline.addLast("length-encoder",new LengthFieldPrepender(4));  
    pipeline.addLast("bytearray-encoder",new ByteArrayEncoder());
    pipeline.addLast("handler",new SecureSocketServerhandler2());
}
项目:bigio    文件:MeMemberTCP.java   
public GossipServerThread() {
    gossipBossGroup = new NioEventLoopGroup(GOSSIP_BOSS_THREADS);
    gossipworkerGroup = new NioEventLoopGroup(GOSSIP_WORKER_THREADS);
    try {
        ServerBootstrap b = new ServerBootstrap();
        b.group(gossipBossGroup,gossipworkerGroup)
                .channel(NioServerSocketChannel.class)
                .childHandler(new ChannelInitializer<SocketChannel>() {
                    @Override
                    public void initChannel(SocketChannel ch) throws Exception {
                        ch.config().setAllocator(UnpooledByteBufAllocator.DEFAULT);
                        ch.pipeline().addLast(new GossipMessageDecoder());
                        ch.pipeline().addLast("encoder",new ByteArrayEncoder());
                        ch.pipeline().addLast("decoder",new ByteArrayDecoder());
                        ch.pipeline().addLast(new GossipMessageHandler());
                        if(LOG.isTraceEnabled()) {
                            ch.pipeline().addLast(new LoggingHandler(LogLevel.TRACE));
                        }
                    }

                    @Override
                    public void exceptionCaught(ChannelHandlerContext ctx,Throwable cause) throws Exception {
                        LOG.error("Cannot initialize gossip server.",cause);
                    }
                })
                .option(ChannelOption.so_BACKLOG,128)
                .childOption(ChannelOption.so_KEEPALIVE,true);

        // Bind and start to accept incoming connections.
        f = b.bind(getIp(),getGossipPort()).sync();
    } catch (InterruptedException ex) {
        LOG.error("Gossip server interrupted.",ex);
    }
}
项目:bigio    文件:MeMemberTCP.java   
public DataServerThread() {
    dataBossGroup = new NioEventLoopGroup(DATA_BOSS_THREADS);
    dataWorkerGroup = new NioEventLoopGroup(DATA_WORKER_THREADS);
    try {
        ServerBootstrap b = new ServerBootstrap();
        b.group(dataBossGroup,dataWorkerGroup)
                .channel(NioServerSocketChannel.class)
                .childHandler(new ChannelInitializer<SocketChannel>() {
                    @Override
                    public void initChannel(SocketChannel ch) throws Exception {
                        ch.config().setAllocator(UnpooledByteBufAllocator.DEFAULT);
                        if(useSSL) {
                            ch.pipeline().addLast(sslContext.newHandler(ch.alloc()));
                        }
                        ch.pipeline().addLast(new LengthFieldBasedFrameDecoder(32768,2,2));
                        ch.pipeline().addLast("decoder",new ByteArrayDecoder());
                        ch.pipeline().addLast(new DataMessageHandler());
                        if(LOG.isTraceEnabled()) {
                            ch.pipeline().addLast(new LoggingHandler(LogLevel.TRACE));
                        }
                    }

                    @Override
                    public void exceptionCaught(ChannelHandlerContext ctx,Throwable cause) throws Exception {
                        LOG.error("Cannot initialize data server.",cause);
                    }
                })
                .option(ChannelOption.so_SNDBUF,262144)
                .option(ChannelOption.so_RCVBUF,262144)
                .option(ChannelOption.so_BACKLOG,getDataPort()).sync();
    } catch (InterruptedException ex) {
        LOG.error("Message data interrupted.",ex);
    }
}
项目:bigio    文件:MeMemberUDP.java   
public GossipServerThread() {
    gossipBossGroup = new NioEventLoopGroup(GOSSIP_BOSS_THREADS);
    gossipworkerGroup = new NioEventLoopGroup(GOSSIP_WORKER_THREADS);
    try {
        ServerBootstrap b = new ServerBootstrap();
        b.group(gossipBossGroup,new ByteArrayDecoder());
                        ch.pipeline().addLast(new GossipMessageHandler());
                        if (LOG.isTraceEnabled()) {
                            ch.pipeline().addLast(new LoggingHandler(LogLevel.TRACE));
                        }
                    }

                    @Override
                    public void exceptionCaught(ChannelHandlerContext ctx,ex);
    }
}
项目:reef    文件:NettyChannelInitializer.java   
@Override
protected void initChannel(final SocketChannel ch) throws Exception {
  ch.pipeline()
      .addLast("frameDecoder",new LengthFieldBasedFrameDecoder(MAXFRAMELENGTH,4))
      .addLast("bytesDecoder",new ByteArrayDecoder())
      .addLast("frameEncoder",new LengthFieldPrepender(4))
      .addLast("bytesEncoder",new ByteArrayEncoder())
      .addLast("chunker",new ChunkedReadWriteHandler())
      .addLast("handler",handlerFactory.createChannelInboundHandler());
}
项目:uploader    文件:UploadInitializer.java   
@Override
public void initChannel(final SocketChannel ch) throws Exception {
    final ChannelPipeline p = ch.pipeline();

    // add the IP ACL filter first
    if (ipFilter != null) {
        p.addLast("acl",ipFilter);
    }

    if (sslCtx != null) {
        if (configuration.isClientAuth()) {
            final SSLEngine engine = sslCtx.newEngine(ch.alloc());
            engine.setUseClientMode(false);
            engine.setNeedClientAuth(true);

            p.addLast("ssl",new SslHandler(engine));
        } else {
            p.addLast("ssl",sslCtx.newHandler(ch.alloc()));
        }
    }

    // removes idle connections after READER_IDLE_SECONDS seconds
    p.addLast("idleStateHandler",new IdleStateHandler(READER_IDLE_SECONDS,0));

    // authenticate via an ACL and mutual certificates
    p.addLast("auth",new AuthHandler(configuration.isClientAuth()));

    // check to see if the data stream is gzipped or not
    // p.addLast("gzipDetector",new OptionalGzipHandler());

    // break each data chunk by newlines
    p.addLast("line",new LineBasedFrameDecoder(Ints.checkedCast(maxLength),true,true));

    // convert each data chunk into a byte array
    p.addLast("decoder",new ByteArrayDecoder());

    // batch and compress chunks of data up to maxUploadBytes
    p.addLast("batcher",new BatchHandler(maxUploadBytes));

    // upload the batch to S3
    p.addLast("uploader",uploadHandler);
}
项目:bigio    文件:RemoteMemberTCP.java   
private void initializeGossipClient() {
    LOG.trace("Initializing gossip client");

    gossipworkerGroup = new NioEventLoopGroup(GOSSIP_WORKER_THREADS);

    Bootstrap b = new Bootstrap();
    b.group(gossipworkerGroup);
    b.channel(NioSocketChannel.class);
    b.option(ChannelOption.so_KEEPALIVE,true);
    b.option(ChannelOption.CONNECT_TIMEOUT_MILLIS,timeout);
    b.handler(new ChannelInitializer<SocketChannel>() {
        @Override
        public void initChannel(SocketChannel ch) throws Exception {
            ch.config().setAllocator(UnpooledByteBufAllocator.DEFAULT);
            ch.pipeline().addLast("encoder",new ByteArrayEncoder());
            ch.pipeline().addLast("decoder",new ByteArrayDecoder());
            ch.pipeline().addLast(new GossipExceptionHandler());
            if(LOG.isTraceEnabled()) {
                ch.pipeline().addLast(new LoggingHandler(LogLevel.TRACE));
            }
        }

        @Override
        public void exceptionCaught(ChannelHandlerContext ctx,Throwable cause) throws Exception {
            LOG.error("Cannot initialize gossip client.",cause);
            ctx.close();
        }
    });

    // Start the client.
    ChannelFuture future = b.connect(getIp(),getGossipPort()).awaitUninterruptibly();

    if(future.isCancelled()) {
        gossipChannel = null;
    } else if(!future.isSuccess()) {
        gossipChannel = null;
        retryGossipConnection();
    } else {
        gossipChannel = future.channel();
        setStatus(MemberStatus.Alive);
        updateMember();
    }
}
项目:bigio    文件:RemoteMemberTCP.java   
private void initializeDataClient() {
    LOG.trace("Initializing data client");

    dataWorkerGroup = new NioEventLoopGroup(DATA_WORKER_THREADS);

    Bootstrap b = new Bootstrap();
    b.group(dataWorkerGroup)
     .channel(NioSocketChannel.class)
     .option(ChannelOption.so_SNDBUF,262144)
     .option(ChannelOption.so_RCVBUF,262144)
     .option(ChannelOption.so_KEEPALIVE,true)
     .option(ChannelOption.TCP_NODELAY,true)
     .option(ChannelOption.CONNECT_TIMEOUT_MILLIS,timeout)
     .handler(new ChannelInitializer<SocketChannel>() {
        @Override
        public void initChannel(SocketChannel ch) throws Exception {
            ch.config().setAllocator(UnpooledByteBufAllocator.DEFAULT);
            if(useSSL) {
                ch.pipeline().addLast(sslContext.newHandler(ch.alloc(),ip,dataPort));
            }
            ch.pipeline().addLast("encoder",new ByteArrayDecoder());
            ch.pipeline().addLast(new DataExceptionHandler());
            if(LOG.isTraceEnabled()) {
                ch.pipeline().addLast(new LoggingHandler(LogLevel.TRACE));
            }
        }

        @Override
        public void exceptionCaught(ChannelHandlerContext ctx,Throwable cause) throws Exception {
            LOG.error("Cannot initialize data client.",getDataPort()).awaitUninterruptibly();

    if(future.isCancelled()) {
        dataChannel = null;
    } else if(!future.isSuccess()) {
        dataChannel = null;
        retryDataConnection();
    } else {
        dataChannel = future.channel();

        try {
            dataChannel.closeFuture().sync();
        } catch (InterruptedException ex) {
            LOG.debug("Interrupted waiting for client to shutdown.",ex);
        }
    }
}
项目:bigio    文件:RemoteMemberUDP.java   
private void initializeGossipClient() {
    LOG.trace("Initializing gossip client");

    gossipworkerGroup = new NioEventLoopGroup(GOSSIP_WORKER_THREADS);

    Bootstrap b = new Bootstrap();
    b.group(gossipworkerGroup);
    b.channel(NioSocketChannel.class);
    b.option(ChannelOption.so_KEEPALIVE,new ByteArrayDecoder());
            ch.pipeline().addLast(new GossipExceptionHandler());
            if (LOG.isTraceEnabled()) {
                ch.pipeline().addLast(new LoggingHandler(LogLevel.TRACE));
            }
        }

        @Override
        public void exceptionCaught(ChannelHandlerContext ctx,getGossipPort()).awaitUninterruptibly();

    if (future.isCancelled()) {
        gossipChannel = null;
    } else if (!future.isSuccess()) {
        gossipChannel = null;
        retryGossipConnection();
    } else {
        gossipChannel = future.channel();
        setStatus(MemberStatus.Alive);
        updateMember();
    }
}
项目:sds    文件:SocketServerChannelInitializer.java   
@Override
protected void initChannel(SocketChannel ch) throws Exception {

    logger.debug("initChannel-start");

    ProtocolDecoderService protocolDecoderService = null;
    ProtocolEncoderService protocolEncoderService = null;

    try{
        protocolDecoderService = applicationContext.getBean(ProtocolDecoderService.class);
        protocolEncoderService = applicationContext.getBean(ProtocolEncoderService.class);

    }catch (Exception e){
        protocolDecoderService = new DefaultProtocolDecoderService();
        protocolEncoderService = new DefaultProtocolEncoderService();
    }

    logger.debug("initChannel->protocolDecoderService:"+protocolDecoderService);
    logger.debug("initChannel->protocolEncoderService:"+protocolEncoderService);


    ch.pipeline().addLast(ByteArrayDecoder,new ByteArrayDecoder());
    ch.pipeline().addLast(ByteArrayEncoder,new ByteArrayEncoder());

    ch.pipeline().addLast(LengthFieldBasedFrameDecoder,4));

    ch.pipeline().addLast(ProtocolDecoderHandler,new ProtocolDecoderHandler(protocolDecoderService));
    ch.pipeline().addLast(ProtocolEncoderHandler,new ProtocolEncoderHandler(protocolEncoderService));


    ch.pipeline().addLast(SystemTimeOut,new IdleStateHandler(heartTime,TimeUnit.SECONDS));

    ch.pipeline().addLast(SocketHandler,new SocketHandler(socketService));

    logger.debug("initChannel-end");
}

io.netty.handler.codec.bytes.ByteArrayEncoder的实例源码

io.netty.handler.codec.bytes.ByteArrayEncoder的实例源码

项目:JPRE    文件:TestClient.java   
public void start() throws Exception {
    EventLoopGroup group = new NioEventLoopGroup();
    try {
        Bootstrap b = new Bootstrap();
        b.group(group)
                .channel(NioSocketChannel.class)
                .remoteAddress(new InetSocketAddress(this.host,this.port))
                .handler(new ChannelInitializer<SocketChannel>() {
                    @Override
                    protected void initChannel(SocketChannel ch) throws Exception {
                        System.out.println("connected server...");
                        ch.pipeline().addLast(new ByteArrayEncoder());
                        ch.pipeline().addLast(new ByteArrayDecoder());
                        ch.pipeline().addLast(new EchoClientHandler());
                    }
                });

        ChannelFuture cf = b.connect().sync();

        cf.channel().closeFuture().sync();
    } finally {
        group.shutdownGracefully().sync();
    }
}
项目:kaa    文件:AbstractKaaTcpserverInitializer.java   
@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());
}
项目:sds    文件:NettyServerServiceImpl.java   
@Override
public synchronized void start() {
    bossGroup = new NioEventLoopGroup(); // (1)
    workerGroup = new NioEventLoopGroup();
    try {
        b = new ServerBootstrap(); // (2)
        b.group(bossGroup,workerGroup)
                .channel(NioServerSocketChannel.class) // (3)
                .childHandler(new ChannelInitializer<SocketChannel>() { // (4)
                    @Override
                    public void initChannel(SocketChannel ch) throws Exception {

                        ch.pipeline().addLast(new ByteArrayDecoder());
                        ch.pipeline().addLast(new ByteArrayEncoder());

                        ch.pipeline().addLast(new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE,4,4));

                        ch.pipeline().addLast(new IdleStateHandler(heartTime,heartTime,TimeUnit.SECONDS));

                        ch.pipeline().addLast(new DeliveryHandler(deliveryService));

                    }
                })
                .option(ChannelOption.so_BACKLOG,128)          // (5)
                .childOption(ChannelOption.so_KEEPALIVE,true); // (6)

        // Bind and start to accept incoming connections.
        b.bind(settingService.getDeliveryPort());

        logger.info("socket: "+settingService.getDeliveryPort()+" starting....");
        // Wait until the server socket is closed.
        // In this example,this does not happen,but you can do that to gracefully
    } catch (Exception e) {
        e.printstacktrace();
    }
}
项目:Camel    文件:ChannelHandlerFactories.java   
public static ChannelHandlerFactory newByteArrayEncoder(String protocol) {
    if ("udp".equals(protocol)) {
        return new ShareableChannelHandlerFactory(new DatagramPacketByteArrayEncoder());
    } else {
        return new ShareableChannelHandlerFactory(new ByteArrayEncoder());
    }
}
项目:netty-ssl-example    文件:NettySocketClient.java   
public void open(EventLoopGroup eventLoopGroup) throws Exception {
    if (openned.compareAndSet(false,true)) {
        eventloopGroop = eventLoopGroup == null ? new NioEventLoopGroup()
                : eventLoopGroup;
        Bootstrap bootstrap = new Bootstrap();
        final BlockingByteArrayClientHandler handler = new BlockingByteArrayClientHandler(
                this);
        this.clientHandler = handler;
        bootstrap.group(eventloopGroop).channel(NioSocketChannel.class)
                .handler(new ChannelInitializer<SocketChannel>() {
                    @Override
                    protected void initChannel(SocketChannel ch)
                            throws Exception {
                        ChannelPipeline pipeline = ch.pipeline();
                        SSLEngine engine = SecureSocketSslContextFactory
                                .getClientContext().createSSLEngine();
                        engine.setUseClientMode(true);
                        pipeline.addLast("ssl",new SslHandler(engine));
                        pipeline.addLast("length-decoder",new LengthFieldBasedFrameDecoder(
                                        Integer.MAX_VALUE,4));
                        pipeline.addLast("bytearray-decoder",new ByteArrayDecoder());
                        pipeline.addLast("length-encoder",new LengthFieldPrepender(4));
                        pipeline.addLast("bytearray-encoder",new ByteArrayEncoder());
                        pipeline.addLast("handler",handler);
                    }

                });
        channelFuture = bootstrap.connect(this.remoteHost,this.remotePort)
                .sync();
    }
}
项目:netty-ssl-example    文件:SecureSocketServerLengthFrameInitializer.java   
@Override
public void initChannel(SocketChannel ch) throws Exception {
    ChannelPipeline pipeline = ch.pipeline();
    SSLEngine engine =
        SecureSocketSslContextFactory.getServerContext().createSSLEngine();
    engine.setUseClientMode(false);
    pipeline.addLast("ssl",new SslHandler(engine));  
    pipeline.addLast("length-decoder",new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE,4)); 
    pipeline.addLast("bytearray-decoder",new ByteArrayDecoder());
    pipeline.addLast("length-encoder",new LengthFieldPrepender(4));  
    pipeline.addLast("bytearray-encoder",new ByteArrayEncoder());
    pipeline.addLast("handler",new SecureSocketServerhandler2());
}
项目:bigio    文件:MeMemberTCP.java   
public GossipServerThread() {
    gossipBossGroup = new NioEventLoopGroup(GOSSIP_BOSS_THREADS);
    gossipworkerGroup = new NioEventLoopGroup(GOSSIP_WORKER_THREADS);
    try {
        ServerBootstrap b = new ServerBootstrap();
        b.group(gossipBossGroup,gossipworkerGroup)
                .channel(NioServerSocketChannel.class)
                .childHandler(new ChannelInitializer<SocketChannel>() {
                    @Override
                    public void initChannel(SocketChannel ch) throws Exception {
                        ch.config().setAllocator(UnpooledByteBufAllocator.DEFAULT);
                        ch.pipeline().addLast(new GossipMessageDecoder());
                        ch.pipeline().addLast("encoder",new ByteArrayEncoder());
                        ch.pipeline().addLast("decoder",new ByteArrayDecoder());
                        ch.pipeline().addLast(new GossipMessageHandler());
                        if(LOG.isTraceEnabled()) {
                            ch.pipeline().addLast(new LoggingHandler(LogLevel.TRACE));
                        }
                    }

                    @Override
                    public void exceptionCaught(ChannelHandlerContext ctx,Throwable cause) throws Exception {
                        LOG.error("Cannot initialize gossip server.",cause);
                    }
                })
                .option(ChannelOption.so_BACKLOG,128)
                .childOption(ChannelOption.so_KEEPALIVE,true);

        // Bind and start to accept incoming connections.
        f = b.bind(getIp(),getGossipPort()).sync();
    } catch (InterruptedException ex) {
        LOG.error("Gossip server interrupted.",ex);
    }
}
项目:bigio    文件:MeMemberUDP.java   
public GossipServerThread() {
    gossipBossGroup = new NioEventLoopGroup(GOSSIP_BOSS_THREADS);
    gossipworkerGroup = new NioEventLoopGroup(GOSSIP_WORKER_THREADS);
    try {
        ServerBootstrap b = new ServerBootstrap();
        b.group(gossipBossGroup,new ByteArrayDecoder());
                        ch.pipeline().addLast(new GossipMessageHandler());
                        if (LOG.isTraceEnabled()) {
                            ch.pipeline().addLast(new LoggingHandler(LogLevel.TRACE));
                        }
                    }

                    @Override
                    public void exceptionCaught(ChannelHandlerContext ctx,ex);
    }
}
项目:reef    文件:NettyChannelInitializer.java   
@Override
protected void initChannel(final SocketChannel ch) throws Exception {
  ch.pipeline()
      .addLast("frameDecoder",new LengthFieldBasedFrameDecoder(MAXFRAMELENGTH,4))
      .addLast("bytesDecoder",new ByteArrayDecoder())
      .addLast("frameEncoder",new LengthFieldPrepender(4))
      .addLast("bytesEncoder",new ByteArrayEncoder())
      .addLast("chunker",new ChunkedReadWriteHandler())
      .addLast("handler",handlerFactory.createChannelInboundHandler());
}
项目:bigio    文件:RemoteMemberTCP.java   
private void initializeGossipClient() {
    LOG.trace("Initializing gossip client");

    gossipworkerGroup = new NioEventLoopGroup(GOSSIP_WORKER_THREADS);

    Bootstrap b = new Bootstrap();
    b.group(gossipworkerGroup);
    b.channel(NioSocketChannel.class);
    b.option(ChannelOption.so_KEEPALIVE,true);
    b.option(ChannelOption.CONNECT_TIMEOUT_MILLIS,timeout);
    b.handler(new ChannelInitializer<SocketChannel>() {
        @Override
        public void initChannel(SocketChannel ch) throws Exception {
            ch.config().setAllocator(UnpooledByteBufAllocator.DEFAULT);
            ch.pipeline().addLast("encoder",new ByteArrayEncoder());
            ch.pipeline().addLast("decoder",new ByteArrayDecoder());
            ch.pipeline().addLast(new GossipExceptionHandler());
            if(LOG.isTraceEnabled()) {
                ch.pipeline().addLast(new LoggingHandler(LogLevel.TRACE));
            }
        }

        @Override
        public void exceptionCaught(ChannelHandlerContext ctx,Throwable cause) throws Exception {
            LOG.error("Cannot initialize gossip client.",cause);
            ctx.close();
        }
    });

    // Start the client.
    ChannelFuture future = b.connect(getIp(),getGossipPort()).awaitUninterruptibly();

    if(future.isCancelled()) {
        gossipChannel = null;
    } else if(!future.isSuccess()) {
        gossipChannel = null;
        retryGossipConnection();
    } else {
        gossipChannel = future.channel();
        setStatus(MemberStatus.Alive);
        updateMember();
    }
}
项目:bigio    文件:RemoteMemberTCP.java   
private void initializeDataClient() {
    LOG.trace("Initializing data client");

    dataWorkerGroup = new NioEventLoopGroup(DATA_WORKER_THREADS);

    Bootstrap b = new Bootstrap();
    b.group(dataWorkerGroup)
     .channel(NioSocketChannel.class)
     .option(ChannelOption.so_SNDBUF,262144)
     .option(ChannelOption.so_RCVBUF,262144)
     .option(ChannelOption.so_KEEPALIVE,true)
     .option(ChannelOption.TCP_NODELAY,true)
     .option(ChannelOption.CONNECT_TIMEOUT_MILLIS,timeout)
     .handler(new ChannelInitializer<SocketChannel>() {
        @Override
        public void initChannel(SocketChannel ch) throws Exception {
            ch.config().setAllocator(UnpooledByteBufAllocator.DEFAULT);
            if(useSSL) {
                ch.pipeline().addLast(sslContext.newHandler(ch.alloc(),ip,dataPort));
            }
            ch.pipeline().addLast("encoder",new ByteArrayDecoder());
            ch.pipeline().addLast(new DataExceptionHandler());
            if(LOG.isTraceEnabled()) {
                ch.pipeline().addLast(new LoggingHandler(LogLevel.TRACE));
            }
        }

        @Override
        public void exceptionCaught(ChannelHandlerContext ctx,Throwable cause) throws Exception {
            LOG.error("Cannot initialize data client.",getDataPort()).awaitUninterruptibly();

    if(future.isCancelled()) {
        dataChannel = null;
    } else if(!future.isSuccess()) {
        dataChannel = null;
        retryDataConnection();
    } else {
        dataChannel = future.channel();

        try {
            dataChannel.closeFuture().sync();
        } catch (InterruptedException ex) {
            LOG.debug("Interrupted waiting for client to shutdown.",ex);
        }
    }
}
项目:bigio    文件:RemoteMemberUDP.java   
private void initializeGossipClient() {
    LOG.trace("Initializing gossip client");

    gossipworkerGroup = new NioEventLoopGroup(GOSSIP_WORKER_THREADS);

    Bootstrap b = new Bootstrap();
    b.group(gossipworkerGroup);
    b.channel(NioSocketChannel.class);
    b.option(ChannelOption.so_KEEPALIVE,new ByteArrayDecoder());
            ch.pipeline().addLast(new GossipExceptionHandler());
            if (LOG.isTraceEnabled()) {
                ch.pipeline().addLast(new LoggingHandler(LogLevel.TRACE));
            }
        }

        @Override
        public void exceptionCaught(ChannelHandlerContext ctx,getGossipPort()).awaitUninterruptibly();

    if (future.isCancelled()) {
        gossipChannel = null;
    } else if (!future.isSuccess()) {
        gossipChannel = null;
        retryGossipConnection();
    } else {
        gossipChannel = future.channel();
        setStatus(MemberStatus.Alive);
        updateMember();
    }
}
项目:sds    文件:SocketServerChannelInitializer.java   
@Override
protected void initChannel(SocketChannel ch) throws Exception {

    logger.debug("initChannel-start");

    ProtocolDecoderService protocolDecoderService = null;
    ProtocolEncoderService protocolEncoderService = null;

    try{
        protocolDecoderService = applicationContext.getBean(ProtocolDecoderService.class);
        protocolEncoderService = applicationContext.getBean(ProtocolEncoderService.class);

    }catch (Exception e){
        protocolDecoderService = new DefaultProtocolDecoderService();
        protocolEncoderService = new DefaultProtocolEncoderService();
    }

    logger.debug("initChannel->protocolDecoderService:"+protocolDecoderService);
    logger.debug("initChannel->protocolEncoderService:"+protocolEncoderService);


    ch.pipeline().addLast(ByteArrayDecoder,new ByteArrayDecoder());
    ch.pipeline().addLast(ByteArrayEncoder,new ByteArrayEncoder());

    ch.pipeline().addLast(LengthFieldBasedFrameDecoder,4));

    ch.pipeline().addLast(ProtocolDecoderHandler,new ProtocolDecoderHandler(protocolDecoderService));
    ch.pipeline().addLast(ProtocolEncoderHandler,new ProtocolEncoderHandler(protocolEncoderService));


    ch.pipeline().addLast(SystemTimeOut,new IdleStateHandler(heartTime,TimeUnit.SECONDS));

    ch.pipeline().addLast(SocketHandler,new SocketHandler(socketService));

    logger.debug("initChannel-end");
}

我们今天的关于头条搜索Bytespider IP反解析头条signature反爬的分享已经告一段落,感谢您的关注,如果您想了解更多关于com.bumptech.glide.load.resource.bytes.BytesResource的实例源码、delphi – 我应该如何调整我的代码以实现TBytes和TIdBytes之间的兼容性?、io.netty.handler.codec.bytes.ByteArrayDecoder的实例源码、io.netty.handler.codec.bytes.ByteArrayEncoder的实例源码的相关信息,请在本站查询。

本文标签: