Retry on certain timeouts, and properly synchronize timeouts.
git-svn-id: file:///home/svn/framework3/trunk@12075 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
a5c3987b33
commit
1a68ab3b07
Binary file not shown.
|
@ -139,7 +139,7 @@ public class InteractWindow extends MsfFrame implements ClipboardOwner {
|
|||
lock.lock();
|
||||
this.publish("unlocked");
|
||||
}
|
||||
try {
|
||||
try { //Get data, append to window, and send notification for prompt
|
||||
long start = System.currentTimeMillis();
|
||||
Map received = (Map) rpcConn.execute(cmdPrefix+"read",sid);
|
||||
time = System.currentTimeMillis() - start;
|
||||
|
@ -156,7 +156,8 @@ public class InteractWindow extends MsfFrame implements ClipboardOwner {
|
|||
} catch (MsfException ex) {
|
||||
if(!ex.getMessage().equals("unknown session"))
|
||||
JOptionPane.showMessageDialog(null, ex);
|
||||
timerCommand.setCharAt(0, STOP_POLLING);
|
||||
if(!ex.getMessage().contains("timed out")) // on timeout, just retry
|
||||
timerCommand.setCharAt(0, STOP_POLLING);
|
||||
}
|
||||
lock.unlock();
|
||||
try {
|
||||
|
@ -174,15 +175,15 @@ public class InteractWindow extends MsfFrame implements ClipboardOwner {
|
|||
}else if(o.equals("unlocked")){
|
||||
submitButton.setEnabled(true);
|
||||
inputField.setEditable(true);
|
||||
}else if(o instanceof Map){
|
||||
}else if(o instanceof Map){ //Update prompt if received
|
||||
checkPrompt((Map)o);
|
||||
}else{
|
||||
}else{ //Data printed, scroll to end
|
||||
outputArea.setCaretPosition(outputArea.getDocument().getLength());
|
||||
}
|
||||
}
|
||||
}
|
||||
}.execute();
|
||||
|
||||
|
||||
if(type.equals("meterpreter"))
|
||||
inputField.setText("help");
|
||||
outputArea.setFont(new Font("Monospaced", outputArea.getFont().getStyle(), 12));
|
||||
|
|
|
@ -229,10 +229,11 @@ public class MainFrame extends FrameView {
|
|||
i++;
|
||||
}
|
||||
publish((Object)jobStrings);
|
||||
} catch (MsfException xre) {
|
||||
xre.printStackTrace();
|
||||
publish("Error getting session list"+xre);
|
||||
return new ArrayList();
|
||||
} catch (MsfException msfEx) {
|
||||
msfEx.printStackTrace();
|
||||
publish("Error getting session list"+msfEx);
|
||||
if(!msfEx.getMessage().contains("timed out")) // on timeout, just retry
|
||||
return new ArrayList();
|
||||
} catch (InterruptedException iex){
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,23 +185,23 @@ public class RpcConnection {
|
|||
|
||||
/** Method that sends a call to the server and received a response; only allows one at a time */
|
||||
private Map exec (String methname, Object[] params) throws MsfException{
|
||||
try{
|
||||
synchronized(lockObject){ //Only one method call at a time!
|
||||
synchronized(lockObject){ //Only one method call at a time!
|
||||
try{
|
||||
writeCall(methname, params);
|
||||
return (Map)readResp();
|
||||
}catch(Exception ex){ //any weirdness gets wrapped in a MsfException
|
||||
try{
|
||||
if(ex instanceof java.net.SocketTimeoutException)
|
||||
reconnect(); //reconnect on socket timeout
|
||||
}catch (Exception ex2){
|
||||
ex = ex2;
|
||||
}
|
||||
if(! (ex instanceof MsfException)){
|
||||
ex.printStackTrace();
|
||||
throw new MsfException("Error in call: "+ex.getLocalizedMessage(), ex);
|
||||
}
|
||||
throw (MsfException)ex;
|
||||
}
|
||||
}catch(Exception ex){ //any weirdness gets wrapped in a MsfException
|
||||
try{
|
||||
if(ex instanceof java.net.SocketTimeoutException) //reconnect on socket timeout
|
||||
reconnect();
|
||||
}catch (Exception ex2){
|
||||
ex = ex2;
|
||||
}
|
||||
if(! (ex instanceof MsfException)){
|
||||
ex.printStackTrace();
|
||||
throw new MsfException("Error in call: "+ex.getLocalizedMessage(), ex);
|
||||
}
|
||||
throw (MsfException)ex;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue