congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
SocksMethod
Code IndexAdd Tabnine to your IDE (free)

How to use
SocksMethod
in
sockslib.common.methods

Best Java code snippets using sockslib.common.methods.SocksMethod (Showing top 16 results out of 315)

origin: theotherp/nzbhydra2

/**
 * 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());
}
origin: theotherp/nzbhydra2

/**
 * 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);
}
origin: theotherp/nzbhydra2

logger.debug("SESSION[{}] Response client:{}", session.getId(), selectedMethod.getMethodName());
selectedMethod.doMethod(session);
origin: theotherp/nzbhydra2

@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);
}
origin: fengyouchao/sockslib

logger.debug("SESSION[{}] Response client:{}", session.getId(), selectedMethod.getMethodName());
selectedMethod.doMethod(session);
origin: fengyouchao/sockslib

@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);
}
origin: fengyouchao/sockslib

/**
 * 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());
}
origin: fengyouchao/sockslib

/**
 * 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);
}
origin: theotherp/nzbhydra2

/**
 * Constructs an instance of {@link MethodSelectionResponseMessage} with a method.
 *
 * @param socksMethod Selected method.
 */
public MethodSelectionResponseMessage(SocksMethod socksMethod) {
  this(5, socksMethod.getByte());
}
origin: fengyouchao/sockslib

/**
 * Constructs an instance of {@link MethodSelectionResponseMessage} with a method.
 *
 * @param socksMethod Selected method.
 */
public MethodSelectionResponseMessage(SocksMethod socksMethod) {
 this(5, socksMethod.getByte());
}
origin: theotherp/nzbhydra2

@Override
public boolean equals(Object obj) {
  return obj instanceof SocksMethod && ((SocksMethod) obj).getByte() == this.getByte();
}
origin: fengyouchao/sockslib

@Override
public boolean equals(Object obj) {
 return obj instanceof SocksMethod && ((SocksMethod) obj).getByte() == this.getByte();
}
origin: theotherp/nzbhydra2

@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();
}
origin: fengyouchao/sockslib

@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();
}
origin: theotherp/nzbhydra2

@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]);
}
origin: fengyouchao/sockslib

@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]);
}
sockslib.common.methodsSocksMethod

Javadoc

The interface SocksMethod define a socks method in SOCKS4 or SOCKS5 protocol.

SOCKS5 protocol in RFC 1928:
The values currently defined for METHOD are:
  • X’00’ NO AUTHENTICATION REQUIRED
  • X’01’ GSSAPI
  • X’02’ USERNAME/PASSWORD
  • X’03’ to X’7F’ IANA ASSIGNED
  • X’80’ to X’FE’ RESERVED FOR PRIVATE METHODS
  • X’FF’ NO ACCEPTABLE METHODS

Most used methods

  • doMethod
    Do method job. This method will be called by SOCKS server.
  • getByte
    method byte.
  • getMethodName
    Gets method's name.

Popular in Java

  • Reading from database using SQL prepared statement
  • getExternalFilesDir (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getContentResolver (Context)
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • JTable (javax.swing)
  • 14 Best Plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now