- Add the Codota plugin to your IDE and get smart completions
private void myMethod () {}
/** * Constructs an instance of {@link MethodSelectionResponseMessage} with a version and a method. * * @param version Version. * @param socksMethod Selected method. */ public MethodSelectionResponseMessage(int version, SocksMethod socksMethod) { this(version, socksMethod.getByte()); }
/** * Puts a {@link SocksMethod} class into the SOCKS method registry with an instance of * {@link SocksMethod}. * * @param socksMethod The instance of {@link SocksMethod}. */ public static void putMethod(SocksMethod socksMethod) { checkNotNull(socksMethod, "Argument [socksMethod] may not be null"); logger.debug("Register {}[{}]", socksMethod.getMethodName(), socksMethod.getByte()); methods.put((byte) socksMethod.getByte(), socksMethod); }
logger.debug("SESSION[{}] Response client:{}", session.getId(), selectedMethod.getMethodName()); selectedMethod.doMethod(session);
@Override public void buildConnection() throws SocksException, IOException { if (inetAddress == null) { throw new IllegalArgumentException("Please set inetAddress before calling buildConnection."); } if (proxySocket == null) { proxySocket = createProxySocket(inetAddress, port); } else if (!proxySocket.isConnected()) { proxySocket.connect(new InetSocketAddress(inetAddress, port)); } SocksMethod method = socksMethodRequester.doRequest(acceptableMethods, proxySocket, SOCKS_VERSION); method.doMethod(this); }
logger.debug("SESSION[{}] Response client:{}", session.getId(), selectedMethod.getMethodName()); selectedMethod.doMethod(session);
@Override public void buildConnection() throws SocksException, IOException { if (inetAddress == null) { throw new IllegalArgumentException("Please set inetAddress before calling buildConnection."); } if (proxySocket == null) { proxySocket = createProxySocket(inetAddress, port); } else if (!proxySocket.isConnected()) { proxySocket.connect(new InetSocketAddress(inetAddress, port)); } SocksMethod method = socksMethodRequester.doRequest(acceptableMethods, proxySocket, SOCKS_VERSION); method.doMethod(this); }
/** * Constructs an instance of {@link MethodSelectionResponseMessage} with a version and a method. * * @param version Version. * @param socksMethod Selected method. */ public MethodSelectionResponseMessage(int version, SocksMethod socksMethod) { this(version, socksMethod.getByte()); }
/** * Puts a {@link SocksMethod} class into the SOCKS method registry with an instance of * {@link SocksMethod}. * * @param socksMethod The instance of {@link SocksMethod}. */ public static void putMethod(SocksMethod socksMethod) { checkNotNull(socksMethod, "Argument [socksMethod] may not be null"); logger.debug("Register {}[{}]", socksMethod.getMethodName(), socksMethod.getByte()); methods.put((byte) socksMethod.getByte(), socksMethod); }
/** * Constructs an instance of {@link MethodSelectionResponseMessage} with a method. * * @param socksMethod Selected method. */ public MethodSelectionResponseMessage(SocksMethod socksMethod) { this(5, socksMethod.getByte()); }
/** * Constructs an instance of {@link MethodSelectionResponseMessage} with a method. * * @param socksMethod Selected method. */ public MethodSelectionResponseMessage(SocksMethod socksMethod) { this(5, socksMethod.getByte()); }
@Override public boolean equals(Object obj) { return obj instanceof SocksMethod && ((SocksMethod) obj).getByte() == this.getByte(); }
@Override public boolean equals(Object obj) { return obj instanceof SocksMethod && ((SocksMethod) obj).getByte() == this.getByte(); }
@Override public SocksMethod select(MethodSelectionMessage message) { int[] methods = message.getMethods(); for (int i = 0; i < methods.length; i++) { for (SocksMethod method : supportMethods) { if (method.getByte() == methods[i]) { return method; } } } return new NoAcceptableMethod(); }
@Override public SocksMethod select(MethodSelectionMessage message) { int[] methods = message.getMethods(); for (int i = 0; i < methods.length; i++) { for (SocksMethod method : supportMethods) { if (method.getByte() == methods[i]) { return method; } } } return new NoAcceptableMethod(); }
@Override public SocksMethod doRequest(List<SocksMethod> acceptableMethods, Socket socket, int socksVersion) throws SocksException, IOException { InputStream inputStream = socket.getInputStream(); OutputStream outputStream = socket.getOutputStream(); byte[] bufferSent = new byte[2 + acceptableMethods.size()]; bufferSent[0] = (byte) socksVersion; bufferSent[1] = (byte) acceptableMethods.size(); for (int i = 0; i < acceptableMethods.size(); i++) { bufferSent[2 + i] = (byte) acceptableMethods.get(i).getByte(); } outputStream.write(bufferSent); outputStream.flush(); logger.debug("{}", LogMessageBuilder.build(bufferSent, MsgType.SEND)); // Received data. byte[] receivedData = StreamUtil.read(inputStream, 2); logger.debug("{}", LogMessageBuilder.build(receivedData, MsgType.RECEIVE)); if (receivedData[0] != socksVersion) { throw new SocksException("Remote server don't support SOCKS5"); } return SocksMethodRegistry.getByByte(receivedData[1]); }
@Override public SocksMethod doRequest(List<SocksMethod> acceptableMethods, Socket socket, int socksVersion) throws SocksException, IOException { InputStream inputStream = socket.getInputStream(); OutputStream outputStream = socket.getOutputStream(); byte[] bufferSent = new byte[2 + acceptableMethods.size()]; bufferSent[0] = (byte) socksVersion; bufferSent[1] = (byte) acceptableMethods.size(); for (int i = 0; i < acceptableMethods.size(); i++) { bufferSent[2 + i] = (byte) acceptableMethods.get(i).getByte(); } outputStream.write(bufferSent); outputStream.flush(); logger.debug("{}", LogMessageBuilder.build(bufferSent, MsgType.SEND)); // Received data. byte[] receivedData = StreamUtil.read(inputStream, 2); logger.debug("{}", LogMessageBuilder.build(receivedData, MsgType.RECEIVE)); if (receivedData[0] != socksVersion) { throw new SocksException("Remote server don't support SOCKS5"); } return SocksMethodRegistry.getByByte(receivedData[1]); }