@Override public void shutdown() { stop = true; executorService.shutdown(); if (thread != null) { thread.interrupt(); } try { closeAllSession(); if (serverSocket != null && serverSocket.isBound()) { serverSocket.close(); } } catch (IOException e) { logger.error(e.getMessage(), e); } }
@Override public void start() throws IOException { serverSocket = createServerSocket(bindPort, bindAddr); thread = new Thread(this); thread.setName("fs-thread"); thread.setDaemon(daemon); thread.start(); }
@Override public void run() { logger.info("Start proxy server at port:{}", bindPort); while (!stop) { try { Socket socket = serverSocket.accept(); socket = processSocketBeforeUse(socket); socket.setSoTimeout(timeout); Session session = sessionManager.newSession(socket); SocksHandler socksHandler = createSocksHandler(); /* initialize socks handler */ socksHandler.setSession(session); initializeSocksHandler(socksHandler); executorService.execute(socksHandler); } catch (IOException e) { // Catches the exception that cause by shutdown method. if (e.getMessage().equals("Socket closed") && stop) { logger.debug("Server shutdown"); return; } logger.debug(e.getMessage(), e); } } }
/** * Creates a no authentication SOCKS5 server. * * @param port The port that SOCKS5 Server will listen. * @return The instance of {@link SocksProxyServer} that supports SOCKS5 protocol. */ public static SocksProxyServer newNoAuthenticationServer(int port) { SocksProxyServer proxyServer = new BasicSocksProxyServer(Socks5Handler.class, port); proxyServer.setBufferSize(BUFFER_SIZE); proxyServer.setTimeout(TIMEOUT); proxyServer.setSupportMethods(new NoAuthenticationRequiredMethod()); return proxyServer; }
/** * Creates a no authentication SOCKS5 server. * * @param port The port that SOCKS5 Server will listen. * @return The instance of {@link SocksProxyServer} that supports SOCKS5 protocol. */ public static SocksProxyServer newNoAuthenticationServer(int port) { SocksProxyServer proxyServer = new BasicSocksProxyServer(Socks5Handler.class, port); proxyServer.setBufferSize(BUFFER_SIZE); proxyServer.setTimeout(TIMEOUT); proxyServer.setSupportMethods(new NoAuthenticationRequiredMethod()); return proxyServer; }
@Override public void run() { logger.info("Start proxy server at port:{}", bindPort); while (!stop) { try { Socket socket = serverSocket.accept(); socket = processSocketBeforeUse(socket); socket.setSoTimeout(timeout); Session session = sessionManager.newSession(socket); SocksHandler socksHandler = createSocksHandler(); /* initialize socks handler */ socksHandler.setSession(session); initializeSocksHandler(socksHandler); executorService.execute(socksHandler); } catch (IOException e) { // Catches the exception that cause by shutdown method. if (e.getMessage().equals("Socket closed") && stop) { logger.debug("Server shutdown"); return; } logger.debug(e.getMessage(), e); } } }
public static SocksProxyServer newUsernamePasswordAuthenticationServer(int port, User... users) { SocksProxyServer proxyServer = new BasicSocksProxyServer(Socks5Handler.class, port); proxyServer.setBufferSize(BUFFER_SIZE); proxyServer.setTimeout(TIMEOUT); UsernamePasswordAuthenticator authenticator = new UsernamePasswordAuthenticator(); for (User user : users) { authenticator.addUser(user.getUsername(), user.getPassword()); } proxyServer.setSupportMethods(new UsernamePasswordMethod(authenticator)); return proxyServer; }
@Override public void start() throws IOException { serverSocket = createServerSocket(bindPort, bindAddr); thread = new Thread(this); thread.setName("fs-thread"); thread.setDaemon(daemon); thread.start(); }
@Override public void shutdown() { stop = true; executorService.shutdown(); if (thread != null) { thread.interrupt(); } try { closeAllSession(); if (serverSocket != null && serverSocket.isBound()) { serverSocket.close(); } } catch (IOException e) { logger.error(e.getMessage(), e); } }
public static SocksProxyServer newUsernamePasswordAuthenticationServer(int port, User... users) { SocksProxyServer proxyServer = new BasicSocksProxyServer(Socks5Handler.class, port); proxyServer.setBufferSize(BUFFER_SIZE); proxyServer.setTimeout(TIMEOUT); UsernamePasswordAuthenticator authenticator = new UsernamePasswordAuthenticator(); for (User user : users) { authenticator.addUser(user.getUsername(), user.getPassword()); } proxyServer.setSupportMethods(new UsernamePasswordMethod(authenticator)); return proxyServer; }
SocksProxyServer proxyServer = null; if (sslConfiguration == null) { proxyServer = new BasicSocksProxyServer(socksHandlerClass); } else { proxyServer = new SSLSocksProxyServer(socksHandlerClass, sslConfiguration);
SocksProxyServer proxyServer = null; if (sslConfiguration == null) { proxyServer = new BasicSocksProxyServer(socksHandlerClass); } else { proxyServer = new SSLSocksProxyServer(socksHandlerClass, sslConfiguration);