本文整理汇总了Java中io.netty.handler.codec.socks.SocksAuthScheme类的典型用法代码示例。如果您正苦于以下问题:Java SocksAuthScheme类的具体用法?Java SocksAuthScheme怎么用?Java SocksAuthScheme使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SocksAuthScheme类属于io.netty.handler.codec.socks包,在下文中一共展示了SocksAuthScheme类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isSocks
import io.netty.handler.codec.socks.SocksAuthScheme; //导入依赖的package包/类
private boolean isSocks(ByteBuf msg) {
switch (SocksProtocolVersion.valueOf(msg.getByte(msg.readerIndex()))) {
case SOCKS5:
case SOCKS4a:
break;
default:
return false;
}
byte numberOfAuthenticationMethods = msg.getByte(msg.readerIndex() + 1);
for (int i = 0; i < numberOfAuthenticationMethods; i++) {
switch (SocksAuthScheme.valueOf(msg.getByte(msg.readerIndex() + 1 + i))) {
case NO_AUTH:
case AUTH_PASSWORD:
case AUTH_GSSAPI:
break;
default:
return false;
}
}
return true;
}
示例2: channelRead0
import io.netty.handler.codec.socks.SocksAuthScheme; //导入依赖的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;
}
}
示例3: channelRead0
import io.netty.handler.codec.socks.SocksAuthScheme; //导入依赖的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;
}
}
示例4: channelRead0
import io.netty.handler.codec.socks.SocksAuthScheme; //导入依赖的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;
}
}
示例5: channelRead0
import io.netty.handler.codec.socks.SocksAuthScheme; //导入依赖的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;
}
}
示例6: messageReceived
import io.netty.handler.codec.socks.SocksAuthScheme; //导入依赖的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;
}
}
示例7: buildInit
import io.netty.handler.codec.socks.SocksAuthScheme; //导入依赖的package包/类
private ByteBuf buildInit() {
ByteBuf buf = Unpooled.buffer();
new SocksInitResponse(SocksAuthScheme.NO_AUTH).encodeAsByteBuf(buf);
return buf;
}