/** * Constructs an instance of {@link MethodSelectionResponseMessage} with a method. * * @param socksMethod Selected method. */ public MethodSelectionResponseMessage(SocksMethod socksMethod) { this(5, socksMethod.getByte()); }
@Override public Socks5 setAcceptableMethods(List<SocksMethod> acceptableMethods) { this.acceptableMethods = acceptableMethods; SocksMethodRegistry.overWriteRegistry(acceptableMethods); return this; }
/** * Constructs a Socks5 instance without any parameter. */ private void init() { acceptableMethods = new ArrayList<>(); acceptableMethods.add(new NoAuthenticationRequiredMethod()); acceptableMethods.add(new GssApiMethod()); acceptableMethods.add(new UsernamePasswordMethod()); }
@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(); }
/** * Builds a {@link SocksProxyServer} which support SOCKS5 protocol bind at a specified port. * This SOCKS5 server will accept all requests from clients with no authentication. * * @param bindPort The port that server listened. * @return Instance of {@link SocksProxyServer}. */ public static SocksProxyServer buildAnonymousSocks5Server(int bindPort) { return newSocks5ServerBuilder().setSocksMethods(new NoAuthenticationRequiredMethod()) .setBindPort(bindPort).build(); }
public static void overWriteRegistry(List<SocksMethod> socksMethods) { checkNotNull(socksMethods, "Argument [socksMethods] may not be null"); for (SocksMethod socksMethod : socksMethods) { putMethod(socksMethod); } }
@Override public int hashCode() { return new Integer(getByte()).hashCode(); }
/** * Constructs a Socks5 instance without any parameter. */ private void init() { acceptableMethods = new ArrayList<>(); acceptableMethods.add(new NoAuthenticationRequiredMethod()); acceptableMethods.add(new GssApiMethod()); acceptableMethods.add(new UsernamePasswordMethod()); }
@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(); }
/** * 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()); }
/** * Builds a {@link SocksProxyServer} which support SOCKS5 protocol bind at a specified port. * This SOCKS5 server will accept all requests from clients with no authentication. * * @param bindPort The port that server listened. * @return Instance of {@link SocksProxyServer}. */ public static SocksProxyServer buildAnonymousSocks5Server(int bindPort) { return newSocks5ServerBuilder().setSocksMethods(new NoAuthenticationRequiredMethod()) .setBindPort(bindPort).build(); }
@Override public Socks5 setAcceptableMethods(List<SocksMethod> acceptableMethods) { this.acceptableMethods = acceptableMethods; SocksMethodRegistry.overWriteRegistry(acceptableMethods); return this; }
public static void overWriteRegistry(List<SocksMethod> socksMethods) { checkNotNull(socksMethods, "Argument [socksMethods] may not be null"); for (SocksMethod socksMethod : socksMethods) { putMethod(socksMethod); } }
@Override public int hashCode() { return new Integer(getByte()).hashCode(); }
/** * 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()); }
/** * Builds a SSL based {@link SocksProxyServer} with no authentication required. * * @param bindPort The port that server listened. * @param configuration SSL configuration * @return Instance of {@link SocksProxyServer} */ public static SocksProxyServer buildAnonymousSSLSocks5Server(int bindPort, SSLConfiguration configuration) { return newSocks5ServerBuilder().setSocksMethods(new NoAuthenticationRequiredMethod()) .setBindPort(bindPort).useSSL(configuration).build(); }
/** * Constructs an instance of {@link MethodSelectionResponseMessage} with a method. * * @param socksMethod Selected method. */ public MethodSelectionResponseMessage(SocksMethod socksMethod) { this(5, socksMethod.getByte()); }
/** * Builds a SSL based {@link SocksProxyServer} with no authentication required. * * @param bindPort The port that server listened. * @param configuration SSL configuration * @return Instance of {@link SocksProxyServer} */ public static SocksProxyServer buildAnonymousSSLSocks5Server(int bindPort, SSLConfiguration configuration) { return newSocks5ServerBuilder().setSocksMethods(new NoAuthenticationRequiredMethod()) .setBindPort(bindPort).useSSL(configuration).build(); }