return serverName;
}
+ @SuppressWarnings("checkstyle:RegexpSinglelineJava")
public void handleCommand(String command) throws IOException {
char[] cbuf = new char[10];
Socket socket;
socket = new Socket(serverName, SERVER_PORT);
} catch (UnknownHostException ioe) {
- session.getConsole().println("No host exists: " + ioe.getMessage());
+ System.out.println("No host exists: " + ioe.getMessage());
return;
} catch (IOException ioe) {
- session.getConsole().println("I/O error occured " + ioe.getMessage());
+ System.out.println("I/O error occured " + ioe.getMessage());
return;
}
try {
inFromSocket = new BufferedReader(new InputStreamReader(socket.getInputStream()));
} catch (IOException ioe) {
- session.getConsole().println("IOException thrown.");
+ System.out.println("IOException thrown.");
socket.close();
return;
}
ret = inFromSocket.read(cbuf);
} catch (SocketTimeoutException ste) {
- session.getConsole().println("Read from Socket timed Out while asking for password.");
+ System.out.println("Read from Socket timed Out while asking for password.");
socket.close();
return;
}
if (ret == -1) {
- session.getConsole().println("Connection closed by BGPd.");
+ System.out.println("Connection closed by BGPd.");
socket.close();
return;
} else {
try {
ip = inFromSocket.read();
} catch (SocketTimeoutException ste) {
- session.getConsole().println(sb.toString());
- session.getConsole().println("Read from Socket timed Out while verifying the password.");
+ System.out.println(sb.toString());
+ System.out.println("Read from Socket timed Out while verifying the password.");
socket.close();
return;
}
}
break;
} else if (ip == -1) {
- session.getConsole().println(sb.toString());
- session.getConsole().println("Connection closed by BGPd.");
+ System.out.println(sb.toString());
+ System.out.println("Connection closed by BGPd.");
socket.close();
return;
} else {
try {
ip = inFromSocket.read();
} catch (SocketTimeoutException ste) {
- session.getConsole().println(sb.toString());
- session.getConsole().println("Read from Socket timed Out while sending the term len command..");
+ System.out.println(sb.toString());
+ System.out.println("Read from Socket timed Out while sending the term len command..");
socket.close();
return;
}
if (ip == gt || ip == hashChar) {
break;
} else if (ip == -1) {
- session.getConsole().println(sb.toString());
- session.getConsole().println("Connection closed by BGPd.");
+ System.out.println(sb.toString());
+ System.out.println("Connection closed by BGPd.");
socket.close();
return;
} else {
}
temp.setLength(0);
}
- session.getConsole().println(output.toString().trim());
+ System.out.println(output.toString().trim());
if (errorMsg.length() > 0) {
- session.getConsole().println(errorMsg);
+ System.out.println(errorMsg);
}
socket.close();
}
return doExecute();
}
- @SuppressWarnings("resource")
+ @SuppressWarnings({"resource", "checkstyle:RegexpSinglelineJava"})
@Override
protected Object doExecute() {
boolean listVrfs = false;
boolean listNets = false;
- PrintStream ps = session.getConsole();
-
+ PrintStream ps = System.out;
if (action != null) {
return usage();
}
fileStream = new PrintStream(ofile);
ps = fileStream;
} catch (FileNotFoundException e) {
- session.getConsole().println("error: cannot create file " + ofile + "; exception: " + e);
+ System.out.println("error: cannot create file " + ofile + "; exception: " + e);
return null;
}
}
listNets = true;
break;
default:
- session.getConsole().println("error: unknown value for " + LST + ": " + item);
+ System.out.println("error: unknown value for " + LST + ": " + item);
if (fileStream != null) {
fileStream.close();
}