executor = Executors.newCachedThreadPool();
}
public void addListeningPort(int port) {
if(port <= 0 || port > 65535) {
throw new TorException("Illegal listening port: "+ port);
}
synchronized(listeningPorts) {
if(isStopped) {
throw new IllegalStateException("Cannot add listening port because Socks proxy has been stopped");
}
if(listeningPorts.contains(port))
return;
listeningPorts.add(port);
try {
startListening(port);
logger.fine("Listening for SOCKS connections on port "+ port);
} catch (IOException e) {
listeningPorts.remove(port);
throw new TorException("Failed to listen on port "+ port +" : "+ e.getMessage());
}
}
}