• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SocksCmdRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.netty.handler.codec.socks.SocksCmdRequest的典型用法代码示例。如果您正苦于以下问题:Java SocksCmdRequest类的具体用法?Java SocksCmdRequest怎么用?Java SocksCmdRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SocksCmdRequest类属于io.netty.handler.codec.socks包,在下文中一共展示了SocksCmdRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getEncodedTargetAddress

import io.netty.handler.codec.socks.SocksCmdRequest; //导入依赖的package包/类
private ByteBuf getEncodedTargetAddress(ByteBufAllocator allocator, boolean resolve) throws ProxyConnectException {
    InetSocketAddress remoteAddress = destinationAddress();
    SocksAddressType remoteAddressType;
    String remoteHost;
    if (!resolve || remoteAddress.isUnresolved()) {
        remoteAddressType = SocksAddressType.DOMAIN;
        remoteHost = remoteAddress.getHostString();
    } else {
        remoteHost = remoteAddress.getAddress().getHostAddress();
        if (NetUtil.isValidIpV4Address(remoteHost)) {
            remoteAddressType = SocksAddressType.IPv4;
        } else if (NetUtil.isValidIpV6Address(remoteHost)) {
            remoteAddressType = SocksAddressType.IPv6;
        } else {
            throw new ProxyConnectException("unknown address type: " + StringUtil.simpleClassName(remoteHost));
        }
    }
    int remotePort = remoteAddress.getPort();
    SocksCmdRequest request = new SocksCmdRequest(SocksCmdType.UNKNOWN, remoteAddressType, remoteHost, remotePort);
    return SSocksAddressEncoder.INSTANCE.encode(allocator, request);
}
 
开发者ID:tridays,项目名称:netty-socks,代码行数:22,代码来源:SSocksConnectHandler.java


示例2: encode

import io.netty.handler.codec.socks.SocksCmdRequest; //导入依赖的package包/类
public ByteBuf encode(ByteBufAllocator allocator, SocksCmdRequest msg) {
    if (LOG.isTraceEnabled()) {
        LOG.trace("encode target address");
    }

    ByteBuf buf = allocator.directBuffer();
    msg.encodeAsByteBuf(buf);
    buf.skipBytes(3);

    if (LOG.isTraceEnabled()) {
        byte[] bytes = new byte[buf.readableBytes()];
        buf.getBytes(buf.readerIndex(), bytes);
    }

    return buf;
}
 
开发者ID:tridays,项目名称:netty-socks,代码行数:17,代码来源:SSocksAddressEncoder.java


示例3: getIpAddr

import io.netty.handler.codec.socks.SocksCmdRequest; //导入依赖的package包/类
/**
 * 获取远程ip地址
 * @param request
 * @return
 */
private String getIpAddr(SocksCmdRequest request) {
	if(isProxy) {
		return config.get_ipAddr();
	} else {
		return request.host();
	}
}
 
开发者ID:breakEval13,项目名称:NSS,代码行数:13,代码来源:SocksServerConnectHandler.java


示例4: getPort

import io.netty.handler.codec.socks.SocksCmdRequest; //导入依赖的package包/类
/**
 * 获取远程端口
 * @param request
 * @return
 */
private int getPort(SocksCmdRequest request) {
	if(isProxy) {
		return config.get_port();
	} else {
		return request.port();
	}
}
 
开发者ID:breakEval13,项目名称:NSS,代码行数:13,代码来源:SocksServerConnectHandler.java


示例5: sendConnectRemoteMessage

import io.netty.handler.codec.socks.SocksCmdRequest; //导入依赖的package包/类
/**
 * localserver和remoteserver进行connect发送的数据
 * 
 * @param request
 * @param outboundChannel
 */
private void sendConnectRemoteMessage(SocksCmdRequest request,
		Channel outboundChannel) {
	ByteBuf buff = Unpooled.buffer();
	request.encodeAsByteBuf(buff);
	if (buff.hasArray()) {
		int len = buff.readableBytes();
		byte[] arr = new byte[len];
		buff.getBytes(0, arr);
		byte[] data = remoteByte(arr);
		sendRemote(data, data.length, outboundChannel);
	}
}
 
开发者ID:breakEval13,项目名称:NSS,代码行数:19,代码来源:SocksServerConnectHandler.java


示例6: channelRead0

import io.netty.handler.codec.socks.SocksCmdRequest; //导入依赖的package包/类
@Override
public void channelRead0(ChannelHandlerContext ctx,
		SocksRequest socksRequest) throws Exception {
	switch (socksRequest.requestType()) {
	case INIT: {
		logger.info("localserver init");
		ctx.pipeline().addFirst(new SocksCmdRequestDecoder());
		ctx.write(new SocksInitResponse(SocksAuthScheme.NO_AUTH));
		break;
	}
	case AUTH:
		ctx.pipeline().addFirst(new SocksCmdRequestDecoder());
		ctx.write(new SocksAuthResponse(SocksAuthStatus.SUCCESS));
		break;
	case CMD:
		SocksCmdRequest req = (SocksCmdRequest) socksRequest;
		if (req.cmdType() == SocksCmdType.CONNECT) {
			logger.info("localserver connect");
			ctx.pipeline().addLast(new SocksServerConnectHandler(config));
			ctx.pipeline().remove(this);
			ctx.fireChannelRead(socksRequest);
		} else {
			ctx.close();
		}
		break;
	case UNKNOWN:
		ctx.close();
		break;
	}
}
 
开发者ID:breakEval13,项目名称:NSS,代码行数:31,代码来源:SocksServerHandler.java


示例7: channelRead0

import io.netty.handler.codec.socks.SocksCmdRequest; //导入依赖的package包/类
@Override
public void channelRead0(ChannelHandlerContext ctx,
        SocksRequest socksRequest) throws Exception {
    switch (socksRequest.requestType()) {
        case INIT: {
            ctx.pipeline().addFirst(new SocksCmdRequestDecoder());
            ctx.write(new SocksInitResponse(SocksAuthScheme.NO_AUTH));
            break;
        }
        case AUTH:
            ctx.pipeline().addFirst(new SocksCmdRequestDecoder());
            ctx.write(new SocksAuthResponse(SocksAuthStatus.SUCCESS));
            break;
        case CMD:
            SocksCmdRequest req = (SocksCmdRequest) socksRequest;
            if (req.cmdType() == SocksCmdType.CONNECT) {
                ctx.pipeline().addLast(new ShadowsocksServerConnectHandler());
                ctx.pipeline().remove(this);
                ctx.fireChannelRead(socksRequest);
            } else {
                ctx.close();
            }
            break;
        case UNKNOWN:
            ctx.close();
            break;
    }
}
 
开发者ID:zhoulifu,项目名称:ss-java,代码行数:29,代码来源:SocksServerHandler.java


示例8: encode

import io.netty.handler.codec.socks.SocksCmdRequest; //导入依赖的package包/类
@Override
protected void encode(ChannelHandlerContext ctx, SocksCmdRequest msg,
        ByteBuf out) throws Exception {
    msg.encodeAsByteBuf(out);
    out.skipBytes(3); // Simply skip first 3 bytes
    ctx.pipeline().remove(this);
}
 
开发者ID:zhoulifu,项目名称:ss-java,代码行数:8,代码来源:ShadowsocksRequestEncoder.java


示例9: channelRead0

import io.netty.handler.codec.socks.SocksCmdRequest; //导入依赖的package包/类
@Override
public void channelRead0(ChannelHandlerContext ctx, SocksRequest socksRequest) throws Exception {
    switch (socksRequest.requestType()) {
        case INIT: {
            // auth support example
            //ctx.pipeline().addFirst(new SocksAuthRequestDecoder());
            //ctx.write(new SocksInitResponse(SocksAuthScheme.AUTH_PASSWORD));
            ctx.pipeline().addFirst(new SocksCmdRequestDecoder());
            ctx.write(new SocksInitResponse(SocksAuthScheme.NO_AUTH));
            break;
        }
        case AUTH:
            ctx.pipeline().addFirst(new SocksCmdRequestDecoder());
            ctx.write(new SocksAuthResponse(SocksAuthStatus.SUCCESS));
            break;
        case CMD:
            SocksCmdRequest req = (SocksCmdRequest) socksRequest;
            if (req.cmdType() == SocksCmdType.CONNECT) {
                ctx.pipeline().addLast(new SocksServerConnectHandler());
                ctx.pipeline().remove(this);
                ctx.fireChannelRead(socksRequest);
            } else {
                ctx.close();
            }
            break;
        case UNKNOWN:
            ctx.close();
            break;
    }
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:31,代码来源:SocksServerHandler.java


示例10: channelRead0

import io.netty.handler.codec.socks.SocksCmdRequest; //导入依赖的package包/类
@Override
    public void channelRead0(ChannelHandlerContext ctx, SocksRequest socksRequest) throws Exception {
        switch (socksRequest.requestType()) {
            case INIT: {
//                auth support example
//                ctx.pipeline().addFirst("socksAuthRequestDecoder",new SocksAuthRequestDecoder());
//                ctx.write(new SocksInitResponse(SocksMessage.SocksAuthScheme.AUTH_PASSWORD));
                ctx.pipeline().addFirst(SocksCmdRequestDecoder.getName(), new SocksCmdRequestDecoder());
                ctx.write(new SocksInitResponse(SocksAuthScheme.NO_AUTH));
                break;
            }
            case AUTH:
                ctx.pipeline().addFirst(SocksCmdRequestDecoder.getName(), new SocksCmdRequestDecoder());
                ctx.write(new SocksAuthResponse(SocksAuthStatus.SUCCESS));
                break;
            case CMD:
                SocksCmdRequest req = (SocksCmdRequest) socksRequest;
                if (req.cmdType() == SocksCmdType.CONNECT) {
                    ctx.pipeline().addLast(SocksServerConnectHandler.getName(), new SocksServerConnectHandler());
                    ctx.pipeline().remove(this);
                    ctx.fireChannelRead(socksRequest);
                } else {
                    ctx.close();
                }
                break;
            case UNKNOWN:
                ctx.close();
                break;
        }
    }
 
开发者ID:kyle-liu,项目名称:netty4study,代码行数:31,代码来源:SocksServerHandler.java


示例11: messageReceived

import io.netty.handler.codec.socks.SocksCmdRequest; //导入依赖的package包/类
@Override
    public void messageReceived(ChannelHandlerContext ctx, SocksRequest socksRequest) throws Exception {
        switch (socksRequest.requestType()) {
            case INIT: {
//                auth support example
//                ctx.pipeline().addFirst("socksAuthRequestDecoder",new SocksAuthRequestDecoder());
//                ctx.write(new SocksInitResponse(SocksMessage.SocksAuthScheme.AUTH_PASSWORD));
                ctx.pipeline().addFirst(SocksCmdRequestDecoder.getName(), new SocksCmdRequestDecoder());
                ctx.write(new SocksInitResponse(SocksAuthScheme.NO_AUTH));
                break;
            }
            case AUTH:
                ctx.pipeline().addFirst(SocksCmdRequestDecoder.getName(), new SocksCmdRequestDecoder());
                ctx.write(new SocksAuthResponse(SocksAuthStatus.SUCCESS));
                break;
            case CMD:
                SocksCmdRequest req = (SocksCmdRequest) socksRequest;
                if (req.cmdType() == SocksCmdType.CONNECT) {
                    ctx.pipeline().addLast(SocksServerConnectHandler.getName(), new SocksServerConnectHandler());
                    ctx.pipeline().remove(this);
                    ctx.fireChannelRead(socksRequest);
                } else {
                    ctx.close();
                }
                break;
            case UNKNOWN:
                ctx.close();
                break;
        }
    }
 
开发者ID:nathanchen,项目名称:netty-netty-5.0.0.Alpha1,代码行数:31,代码来源:SocksServerHandler.java


示例12: prepare

import io.netty.handler.codec.socks.SocksCmdRequest; //导入依赖的package包/类
private ChannelHandlerContext prepare(final ChannelHandlerContext ctx, Object msg, ChannelFuture future) throws IOException {
	if (msg.getClass() == SocksCmdRequest.class) {
		SocksCmdRequest cmd = SocksCmdRequest.class.cast(msg);
		return Socks5ProxyServerHandlerBuilder.this.exchangerContext.exists(cmd.host()) ? this.activate(Socks5ProxyServerHandlerBuilder.this.exchangerContext.activate(cmd.host()), future, ctx) : this.wait(cmd, ctx);
	}
	return ctx;
}
 
开发者ID:KimShen,项目名称:sissi,代码行数:8,代码来源:Socks5ProxyServerHandlerBuilder.java


示例13: getSuccessResponse

import io.netty.handler.codec.socks.SocksCmdRequest; //导入依赖的package包/类
private SocksCmdResponse getSuccessResponse(SocksCmdRequest request) {
	return new SocksCmdResponse(SocksCmdStatus.SUCCESS,
			request.addressType());
}
 
开发者ID:breakEval13,项目名称:NSS,代码行数:5,代码来源:SocksServerConnectHandler.java


示例14: getFailureResponse

import io.netty.handler.codec.socks.SocksCmdRequest; //导入依赖的package包/类
private SocksCmdResponse getFailureResponse(SocksCmdRequest request) {
	return new SocksCmdResponse(SocksCmdStatus.FAILURE,
			request.addressType());
}
 
开发者ID:breakEval13,项目名称:NSS,代码行数:5,代码来源:SocksServerConnectHandler.java


示例15: wait

import io.netty.handler.codec.socks.SocksCmdRequest; //导入依赖的package包/类
/**
 * 禁止关闭接收方,cascade = false
 * 
 * @param cmd
 * @param ctx
 * @return
 * @throws IOException
 */
private ChannelHandlerContext wait(SocksCmdRequest cmd, ChannelHandlerContext ctx) throws IOException {
	ctx.attr(Socks5ProxyServerHandlerBuilder.this.exchanger).set(Socks5ProxyServerHandlerBuilder.this.exchangerContext.wait(cmd.host(), false, new NetworkTransfer(ctx)));
	return ctx;
}
 
开发者ID:KimShen,项目名称:sissi,代码行数:13,代码来源:Socks5ProxyServerHandlerBuilder.java



注:本文中的io.netty.handler.codec.socks.SocksCmdRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RunnerRegistry类代码示例发布时间:2022-05-22
下一篇:
Java ServiceFactory类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap