forked from I2P_Developers/i2p.i2p
* Console:
- Add SSL support - To enable, change clients.config. Examples:
## Change to SSL only - just add a '-s'
clientApp.0.args=-s 7657 ::1,127.0.0.1 ./webapps/
## Use both non-SSL and SSL - add '-s port interface'
clientApp.0.args=7657 ::1,127.0.0.1 -s 7667 ::1,127.0.0.1 ./webapps/
## ...and change URLLauncher args further down for the browser to open https:// at startup if you like.
This commit is contained in:
@@ -51,17 +51,18 @@ public class ShellCommand {
|
||||
*/
|
||||
private class CommandThread extends Thread {
|
||||
|
||||
final Object caller;
|
||||
boolean consumeOutput;
|
||||
String shellCommand;
|
||||
private final Object caller;
|
||||
private final boolean consumeOutput;
|
||||
private final Object shellCommand;
|
||||
|
||||
CommandThread(Object caller, String shellCommand, boolean consumeOutput) {
|
||||
/**
|
||||
* @param shellCommand either a String or a String[] (since 0.8.3)
|
||||
*/
|
||||
CommandThread(Object caller, Object shellCommand, boolean consumeOutput) {
|
||||
super("CommandThread");
|
||||
this.caller = caller;
|
||||
this.shellCommand = shellCommand;
|
||||
this.consumeOutput = consumeOutput;
|
||||
_commandSuccessful = false;
|
||||
_commandCompleted = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -200,6 +201,9 @@ public class ShellCommand {
|
||||
* {@link #getErrorStream()}, respectively. Input can be passed to the
|
||||
* <code>STDIN</code> of the shell process via {@link #getInputStream()}.
|
||||
*
|
||||
* Warning, no good way to quote or escape spaces in arguments with this method.
|
||||
* @deprecated unused
|
||||
*
|
||||
* @param shellCommand The command for the shell to execute.
|
||||
*/
|
||||
public void execute(String shellCommand) {
|
||||
@@ -215,6 +219,9 @@ public class ShellCommand {
|
||||
* Input can be passed to the <code>STDIN</code> of the shell process via
|
||||
* {@link #getInputStream()}.
|
||||
*
|
||||
* Warning, no good way to quote or escape spaces in arguments with this method.
|
||||
* @deprecated unused
|
||||
*
|
||||
* @param shellCommand The command for the shell to execute.
|
||||
* @return <code>true</code> if the spawned shell process
|
||||
* returns an exit status of 0 (indicating success),
|
||||
@@ -237,6 +244,9 @@ public class ShellCommand {
|
||||
* {@link #getErrorStream()}, respectively. Input can be passed to the
|
||||
* <code>STDIN</code> of the shell process via {@link #getInputStream()}.
|
||||
*
|
||||
* Warning, no good way to quote or escape spaces in arguments with this method.
|
||||
* @deprecated unused
|
||||
*
|
||||
* @param shellCommand The command for the shell to execute.
|
||||
* @param seconds The method will return <code>true</code> if this
|
||||
* number of seconds elapses without the process
|
||||
@@ -276,6 +286,9 @@ public class ShellCommand {
|
||||
* without waiting for an exit status. Any output produced by the executed
|
||||
* command will not be displayed.
|
||||
*
|
||||
* Warning, no good way to quote or escape spaces in arguments with this method.
|
||||
* @deprecated unused
|
||||
*
|
||||
* @param shellCommand The command for the shell to execute.
|
||||
* @throws IOException
|
||||
*/
|
||||
@@ -288,6 +301,8 @@ public class ShellCommand {
|
||||
* all of the command's resulting shell processes have completed. Any output
|
||||
* produced by the executed command will not be displayed.
|
||||
*
|
||||
* Warning, no good way to quote or escape spaces in arguments with this method.
|
||||
*
|
||||
* @param shellCommand The command for the shell to execute.
|
||||
* @return <code>true</code> if the spawned shell process
|
||||
* returns an exit status of 0 (indicating success),
|
||||
@@ -307,7 +322,12 @@ public class ShellCommand {
|
||||
* specified number of seconds has elapsed first. Any output produced by the
|
||||
* executed command will not be displayed.
|
||||
*
|
||||
* @param shellCommand The command for the shell to execute.
|
||||
* Warning, no good way to quote or escape spaces in arguments when shellCommand is a String.
|
||||
* Use a String array for best results, especially on Windows.
|
||||
*
|
||||
* @param shellCommand The command for the shell to execute, as a String.
|
||||
* You can't quote arguments successfully.
|
||||
* See Runtime.exec(String) for more info.
|
||||
* @param seconds The method will return <code>true</code> if this
|
||||
* number of seconds elapses without the process
|
||||
* returning an exit status. A value of <code>0</code>
|
||||
@@ -317,7 +337,33 @@ public class ShellCommand {
|
||||
* else <code>false</code>.
|
||||
*/
|
||||
public synchronized boolean executeSilentAndWaitTimed(String shellCommand, int seconds) {
|
||||
return executeSAWT(shellCommand, seconds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes a command to the shell for execution. This method blocks until
|
||||
* all of the command's resulting shell processes have completed unless a
|
||||
* specified number of seconds has elapsed first. Any output produced by the
|
||||
* executed command will not be displayed.
|
||||
*
|
||||
* @param commandArray The command for the shell to execute,
|
||||
* as a String[].
|
||||
* See Runtime.exec(String[]) for more info.
|
||||
* @param seconds The method will return <code>true</code> if this
|
||||
* number of seconds elapses without the process
|
||||
* returning an exit status. A value of <code>0</code>
|
||||
* here disables waiting.
|
||||
* @return <code>true</code> if the spawned shell process
|
||||
* returns an exit status of 0 (indicating success),
|
||||
* else <code>false</code>.
|
||||
* @since 0.8.3
|
||||
*/
|
||||
public synchronized boolean executeSilentAndWaitTimed(String[] commandArray, int seconds) {
|
||||
return executeSAWT(commandArray, seconds);
|
||||
}
|
||||
|
||||
/** @since 0.8.3 */
|
||||
private boolean executeSAWT(Object shellCommand, int seconds) {
|
||||
_commandThread = new CommandThread(this, shellCommand, CONSUME_OUTPUT);
|
||||
_commandThread.start();
|
||||
try {
|
||||
@@ -364,7 +410,10 @@ public class ShellCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
private boolean execute(String shellCommand, boolean consumeOutput, boolean waitForExitStatus) {
|
||||
/**
|
||||
* @param shellCommand either a String or a String[] (since 0.8.3) - quick hack
|
||||
*/
|
||||
private boolean execute(Object shellCommand, boolean consumeOutput, boolean waitForExitStatus) {
|
||||
|
||||
StreamConsumer processStderrConsumer;
|
||||
StreamConsumer processStdoutConsumer;
|
||||
@@ -374,7 +423,13 @@ public class ShellCommand {
|
||||
StreamReader processStdoutReader;
|
||||
|
||||
try {
|
||||
_process = Runtime.getRuntime().exec(shellCommand, null);
|
||||
// easy way so we don't have to copy this whole method
|
||||
if (shellCommand instanceof String)
|
||||
_process = Runtime.getRuntime().exec((String)shellCommand);
|
||||
else if (shellCommand instanceof String[])
|
||||
_process = Runtime.getRuntime().exec((String[])shellCommand);
|
||||
else
|
||||
throw new ClassCastException("shell command must be a String or a String[]");
|
||||
if (consumeOutput) {
|
||||
processStderrConsumer = new StreamConsumer(_process.getErrorStream());
|
||||
processStderrConsumer.start();
|
||||
|
||||
Reference in New Issue
Block a user