// Path: src/main/java/com/github/javawow/auth/AuthServer.java
// public final class AuthServer {
// 	private static final int PORT = 3724;
// 	private static final Logger LOGGER = LoggerFactory.getLogger(AuthServer.class);
// 	private static final Scanner sc = new Scanner(System.in);
// 	private static final EventLoopGroup bossGroup = new NioEventLoopGroup();
// 	private static final EventLoopGroup workerGroup = new NioEventLoopGroup();
// 	public static final AttributeKey<WoWSRP6Server> SRP_ATTR = AttributeKey.newInstance("SRP");
// 
// 	private AuthServer() {
// 	}
// 
// 	public static final void main(String[] args) {
// 		ServerBootstrap b = new ServerBootstrap()
// 				.group(bossGroup, workerGroup)
// 				.channel(NioServerSocketChannel.class)
// 				.childHandler(new ChannelInitializer<Channel>() {
// 					@Override
// 					protected void initChannel(Channel ch) throws Exception {
// 						ch.pipeline().addLast("encoder", AuthEncoder.getInstance());
// 						ch.pipeline().addLast("decoder", new AuthDecoder());
// 						ch.pipeline().addLast("handler", AuthServerHandler.getInstance());
// 					}
// 				})
// 				.option(ChannelOption.SO_BACKLOG, Integer.valueOf(NetUtil.SOMAXCONN))
// 				.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
// 				.childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
// 				.childOption(ChannelOption.TCP_NODELAY, Boolean.TRUE)
// 				.childOption(ChannelOption.SO_KEEPALIVE, Boolean.TRUE);
// 		ChannelFuture cf = b.bind(PORT).addListener(f -> {
// 			if (f.isSuccess()) {
// 				LOGGER.info("Auth Server listening on port {}.", PORT);
// 			} else {
// 				LOGGER.error("Binding to port {} failed", Integer.valueOf(PORT), f.cause());
// 			}
// 		});
// 		// Wait for the bind to complete
// 		try {
// 			cf.await();
// 		} catch (InterruptedException e) {
// 			// Restore interrupted status
// 			Thread.currentThread().interrupt();
// 		}
// 		while (sc.hasNextLine()) {
// 			if (sc.nextLine().equalsIgnoreCase("q")) {
// 				System.out.println("Shutting down...");
// 				workerGroup.shutdownGracefully();
// 				bossGroup.shutdownGracefully();
// 				break;
// 			}
// 		}
// 	}
// }
// 
// Path: src/main/java/com/github/javawow/auth/message/RealmlistRequestMessage.java
// @Immutable
// public final class RealmlistRequestMessage {
// 	private final int unk;
// 
// 	public RealmlistRequestMessage(int unk) {
// 		this.unk = unk;
// 	}
// 
// 	public final int getUnk() {
// 		return unk;
// 	}
// }
// 
// Path: src/main/java/com/github/javawow/data/output/LittleEndianWriterStream.java
// public class LittleEndianWriterStream extends GenericLittleEndianWriter {
// 	private int opcode;
// 	private ByteArrayOutputStream baos;
// 
// 	public LittleEndianWriterStream(int opcode) {
// 		this(opcode, 32);
// 	}
// 
// 	public LittleEndianWriterStream(int opcode, int size) {
// 		this.opcode = opcode;
// 		this.baos = new ByteArrayOutputStream(size);
// 		setByteOutputStream(new ByteArrayOutputByteStream(baos));
// 	}
// 
// //	public final byte[] toByteArray() {
// //		return baos.toByteArray();
// //	}
// 
// //	public final int size() {
// //		return baos.size();
// //	}
// 
// 	public final ByteBufWoWPacket getPacket() {
// 		return new ByteBufWoWPacket(opcode, Unpooled.wrappedBuffer(baos.toByteArray()));
// 	}
// 
// 	@Override
// 	public final String toString() {
// 		return HexTool.toString(baos.toByteArray());
// 	}
// }


import io.netty.channel.Channel;
import com.github.javawow.auth.AuthServer;
import com.github.javawow.auth.message.RealmlistRequestMessage;
import com.github.javawow.data.output.LittleEndianWriterStream;
/*
 * Java World of Warcraft Emulation Project
 * Copyright (C) 2015-2020 JavaWoW
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.github.javawow.auth.handler;



public final class RealmListRequestHandler implements BasicAuthHandler<RealmlistRequestMessage> {
//	private static final Logger LOGGER = LoggerFactory.getLogger(RealmListRequestHandler.class);
	private static final RealmListRequestHandler INSTANCE = new RealmListRequestHandler();

	private RealmListRequestHandler() {
		// singleton
	}

	public static final RealmListRequestHandler getInstance() {
		return INSTANCE;
	}

	@Override
	public final boolean hasValidState(Channel channel) {
// Path: src/main/java/com/github/javawow/auth/AuthServer.java
// public final class AuthServer {
// 	private static final int PORT = 3724;
// 	private static final Logger LOGGER = LoggerFactory.getLogger(AuthServer.class);
// 	private static final Scanner sc = new Scanner(System.in);
// 	private static final EventLoopGroup bossGroup = new NioEventLoopGroup();
// 	private static final EventLoopGroup workerGroup = new NioEventLoopGroup();
// 	public static final AttributeKey<WoWSRP6Server> SRP_ATTR = AttributeKey.newInstance("SRP");
// 
// 	private AuthServer() {
// 	}
// 
// 	public static final void main(String[] args) {
// 		ServerBootstrap b = new ServerBootstrap()
// 				.group(bossGroup, workerGroup)
// 				.channel(NioServerSocketChannel.class)
// 				.childHandler(new ChannelInitializer<Channel>() {
// 					@Override
// 					protected void initChannel(Channel ch) throws Exception {
// 						ch.pipeline().addLast("encoder", AuthEncoder.getInstance());
// 						ch.pipeline().addLast("decoder", new AuthDecoder());
// 						ch.pipeline().addLast("handler", AuthServerHandler.getInstance());
// 					}
// 				})
// 				.option(ChannelOption.SO_BACKLOG, Integer.valueOf(NetUtil.SOMAXCONN))
// 				.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
// 				.childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
// 				.childOption(ChannelOption.TCP_NODELAY, Boolean.TRUE)
// 				.childOption(ChannelOption.SO_KEEPALIVE, Boolean.TRUE);
// 		ChannelFuture cf = b.bind(PORT).addListener(f -> {
// 			if (f.isSuccess()) {
// 				LOGGER.info("Auth Server listening on port {}.", PORT);
// 			} else {
// 				LOGGER.error("Binding to port {} failed", Integer.valueOf(PORT), f.cause());
// 			}
// 		});
// 		// Wait for the bind to complete
// 		try {
// 			cf.await();
// 		} catch (InterruptedException e) {
// 			// Restore interrupted status
// 			Thread.currentThread().interrupt();
// 		}
// 		while (sc.hasNextLine()) {
// 			if (sc.nextLine().equalsIgnoreCase("q")) {
// 				System.out.println("Shutting down...");
// 				workerGroup.shutdownGracefully();
// 				bossGroup.shutdownGracefully();
// 				break;
// 			}
// 		}
// 	}
// }
// 
// Path: src/main/java/com/github/javawow/auth/message/RealmlistRequestMessage.java
// @Immutable
// public final class RealmlistRequestMessage {
// 	private final int unk;
// 
// 	public RealmlistRequestMessage(int unk) {
// 		this.unk = unk;
// 	}
// 
// 	public final int getUnk() {
// 		return unk;
// 	}
// }
// 
// Path: src/main/java/com/github/javawow/data/output/LittleEndianWriterStream.java
// public class LittleEndianWriterStream extends GenericLittleEndianWriter {
// 	private int opcode;
// 	private ByteArrayOutputStream baos;
// 
// 	public LittleEndianWriterStream(int opcode) {
// 		this(opcode, 32);
// 	}
// 
// 	public LittleEndianWriterStream(int opcode, int size) {
// 		this.opcode = opcode;
// 		this.baos = new ByteArrayOutputStream(size);
// 		setByteOutputStream(new ByteArrayOutputByteStream(baos));
// 	}
// 
// //	public final byte[] toByteArray() {
// //		return baos.toByteArray();
// //	}
// 
// //	public final int size() {
// //		return baos.size();
// //	}
// 
// 	public final ByteBufWoWPacket getPacket() {
// 		return new ByteBufWoWPacket(opcode, Unpooled.wrappedBuffer(baos.toByteArray()));
// 	}
// 
// 	@Override
// 	public final String toString() {
// 		return HexTool.toString(baos.toByteArray());
// 	}
// }


// Path: src/main/java/com/github/javawow/auth/handler/RealmListRequestHandler.java
import io.netty.channel.Channel;
import com.github.javawow.auth.AuthServer;
import com.github.javawow.auth.message.RealmlistRequestMessage;
import com.github.javawow.data.output.LittleEndianWriterStream;

/*
 * Java World of Warcraft Emulation Project
 * Copyright (C) 2015-2020 JavaWoW
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.github.javawow.auth.handler;



public final class RealmListRequestHandler implements BasicAuthHandler<RealmlistRequestMessage> {
//	private static final Logger LOGGER = LoggerFactory.getLogger(RealmListRequestHandler.class);
	private static final RealmListRequestHandler INSTANCE = new RealmListRequestHandler();

	private RealmListRequestHandler() {
		// singleton
	}

	public static final RealmListRequestHandler getInstance() {
		return INSTANCE;
	}

	@Override
	public final boolean hasValidState(Channel channel) {
		return channel.attr(AuthServer.SRP_ATTR).get() != null;