/** * Returns a {@link SocksException} instance with a message "Protocol not supported". * * @return An instance of {@link SocksException}. */ public static SocksException protocolNotSupported() { return new SocksException("Protocol not supported"); }
@Override public void doMethod(Session session) throws SocksException, IOException { checkNotNull(session, "Argument [session] may not be null"); session.close(); // close session throw SocksException.noAcceptableMethods(); }
/** * Returns a {@link SocksException} instance with a message of reply. * * @param reply Server's reply. * @return An instance of {@link SocksException}. */ public static SocksException serverReplyException(ServerReply reply) { SocksException ex = serverReplyException(reply.getValue()); ex.setServerReply(reply); return ex; }
socksException = SocksException.serverReplyException(ServerReply.COMMAND_NOT_SUPPORTED); socksException = SocksException.serverReplyException(ServerReply.ADDRESS_TYPE_NOT_SUPPORTED); int domainLength = checkEnd(inputStream.read()); if (domainLength < 1) { throw new SocksException("Length of domain must great than 0"); } catch (UnknownHostException e) { if (socksException == null) { socksException = SocksException.serverReplyException(ServerReply.HOST_UNREACHABLE);
ServerReply serverReply = commandMessage.getSocksException().getServerReply(); session.write(new CommandResponseMessage(serverReply)); logger.info("SESSION[{}] will close, because {}", session.getId(), serverReply);
throw SocksException.serverReplyException(serverReply);
socksException = SocksException.serverReplyException(ServerReply.COMMAND_NOT_SUPPORTED); socksException = SocksException.serverReplyException(ServerReply.ADDRESS_TYPE_NOT_SUPPORTED); int domainLength = checkEnd(inputStream.read()); if (domainLength < 1) { throw new SocksException("Length of domain must great than 0"); } catch (UnknownHostException e) { if (socksException == null) { socksException = SocksException.serverReplyException(ServerReply.HOST_UNREACHABLE);
ServerReply serverReply = commandMessage.getSocksException().getServerReply(); session.write(new CommandResponseMessage(serverReply)); logger.info("SESSION[{}] will close, because {}", session.getId(), serverReply);
throw SocksException.serverReplyException(serverReply);
/** * Returns a {@link SocksException} instance with a message "NO ACCEPTABLE METHODS". * * @return An instance of {@link SocksException}. */ public static SocksException noAcceptableMethods() { return new SocksException(NO_ACCEPTABLE_METHODS); }
/** * Returns a {@link SocksException} instance with a message of reply. * * @param reply Server's reply. * @return An instance of {@link SocksException}. */ public static SocksException serverReplyException(ServerReply reply) { SocksException ex = serverReplyException(reply.getValue()); ex.setServerReply(reply); return ex; }
@Override public void doMethod(Session session) throws SocksException, IOException { checkNotNull(session, "Argument [session] may not be null"); session.close(); // close session throw SocksException.noAcceptableMethods(); }
/** * Returns a {@link SocksException} instance with a message "Protocol not supported". * * @return An instance of {@link SocksException}. */ public static SocksException protocolNotSupported() { return new SocksException("Protocol not supported"); }
@Override public void doMethod(SocksProxy socksProxy) throws SocksException, IOException { checkNotNull(socksProxy, "Argument [socksProxy] may not be null"); // Close socket and throw SocksException. if (!socksProxy.getProxySocket().isClosed()) { socksProxy.getProxySocket().close(); } throw SocksException.noAcceptableMethods(); }
/** * Returns a {@link SocksException} instance with a message "NO ACCEPTABLE METHODS". * * @return An instance of {@link SocksException}. */ public static SocksException noAcceptableMethods() { return new SocksException(NO_ACCEPTABLE_METHODS); }
@Override public void doMethod(SocksProxy socksProxy) throws SocksException, IOException { checkNotNull(socksProxy, "Argument [socksProxy] may not be null"); // Close socket and throw SocksException. if (!socksProxy.getProxySocket().isClosed()) { socksProxy.getProxySocket().close(); } throw SocksException.noAcceptableMethods(); }
/** * Returns a {@link SocksException} instance with a message of reply. * * @param reply Code of server's reply. * @return An instance of {@link SocksException}. */ public static SocksException serverReplyException(byte reply) { int code = reply; code = code & 0xff; if (code < 0 || code > 0x08) { return new SocksException("Unknown reply"); } code = code - 1; return new SocksException(serverReplyMessage[code]); }
/** * Returns a {@link SocksException} instance with a message of reply. * * @param reply Code of server's reply. * @return An instance of {@link SocksException}. */ public static SocksException serverReplyException(byte reply) { int code = reply; code = code & 0xff; if (code < 0 || code > 0x08) { return new SocksException("Unknown reply"); } code = code - 1; return new SocksException(serverReplyMessage[code]); }
@Override protected ServerSocket createServerSocket(int bindPort, InetAddress bindAddr) throws IOException { try { return createSSLServer(bindPort, bindAddr); } catch (Exception e) { throw new SocksException(e.getMessage()); } }
/** * Accepts a connection.<br> * <b>Notice:</b> This method can be called only once. It will throw SocksException if this method * is called more than once. */ @Override public synchronized Socket accept() throws SocksException, IOException { if (alreadyAccepted) { throw new SocksException("SOCKS4/SOCKS5 protocol only allows one income connection"); } alreadyAccepted = true; return proxy.accept(); }