@Override public CommandReplyMessage send(Socket socket, SocksCommand command, String host, int port, int version) throws SocksException, IOException { final InputStream inputStream = socket.getInputStream(); final OutputStream outputStream = socket.getOutputStream(); final int lengthOfHost = host.getBytes().length; final byte[] bufferSent = new byte[7 + lengthOfHost]; bufferSent[0] = (byte) version; bufferSent[1] = (byte) command.getValue(); bufferSent[2] = RESERVED; bufferSent[3] = ATYPE_DOMAINNAME; bufferSent[4] = (byte) lengthOfHost; byte[] bytesOfHost = host.getBytes(); System.arraycopy(bytesOfHost, 0, bufferSent, 5, lengthOfHost);// copy host bytes. bufferSent[5 + host.length()] = (byte) ((port & 0xff00) >> 8); bufferSent[6 + host.length()] = (byte) (port & 0xff); outputStream.write(bufferSent); outputStream.flush(); logger.debug("{}", LogMessageBuilder.build(bufferSent, MsgType.SEND)); return checkServerReply(inputStream); }
@Override public CommandReplyMessage send(Socket socket, SocksCommand command, String host, int port, int version) throws SocksException, IOException { final InputStream inputStream = socket.getInputStream(); final OutputStream outputStream = socket.getOutputStream(); final int lengthOfHost = host.getBytes().length; final byte[] bufferSent = new byte[7 + lengthOfHost]; bufferSent[0] = (byte) version; bufferSent[1] = (byte) command.getValue(); bufferSent[2] = RESERVED; bufferSent[3] = ATYPE_DOMAINNAME; bufferSent[4] = (byte) lengthOfHost; byte[] bytesOfHost = host.getBytes(); System.arraycopy(bytesOfHost, 0, bufferSent, 5, lengthOfHost);// copy host bytes. bufferSent[5 + host.length()] = (byte) ((port & 0xff00) >> 8); bufferSent[6 + host.length()] = (byte) (port & 0xff); outputStream.write(bufferSent); outputStream.flush(); logger.debug("{}", LogMessageBuilder.build(bufferSent, MsgType.SEND)); return checkServerReply(inputStream); }
bufferSent[1] = (byte) command.getValue(); bufferSent[2] = RESERVED; bufferSent[3] = addressType;
bufferSent[1] = (byte) command.getValue(); bufferSent[2] = RESERVED; bufferSent[3] = addressType;
bytes[1] = (byte) command.getValue(); bytes[2] = RESERVED; bytes[3] = (byte) addressType;
bytes[1] = (byte) command.getValue(); bytes[2] = RESERVED; bytes[3] = (byte) addressType;