} catch (Throwable t) {
outsb.append("Insert threw: ").append(t);
t.printStackTrace();
}
} else if(uline.startsWith("MAKESSK")) {
InsertableClientSSK key = InsertableClientSSK.createRandom(r, "");
outsb.append("Insert URI: ").append(key.getInsertURI().toString(false, false)).append("\r\n");
outsb.append("Request URI: ").append(key.getURI().toString(false, false)).append("\r\n");
FreenetURI insertURI = key.getInsertURI().setDocName("testsite");
String fixedInsertURI = insertURI.toString(false, false);
outsb.append("Note that you MUST add a filename to the end of the above URLs e.g.:\r\n").append(fixedInsertURI).append("\r\n");
outsb.append("Normally you will then do PUTSSKDIR:<insert URI>#<directory to upload>, for example:\r\nPUTSSKDIR:").append(fixedInsertURI).append("#directoryToUpload/\r\n");
outsb.append("This will then produce a manifest site containing all the files, the default document can be accessed at\r\n").append(key.getURI().toString(false, false)).append("testsite/");
} else if(uline.startsWith("PUTSSK:")) {
String cmd = line.substring("PUTSSK:".length());
cmd = cmd.trim();
if(cmd.indexOf(';') <= 0) {
outsb.append("No target URI provided.");
outsb.append("PUTSSK:<insert uri>;<url to redirect to>");
outsb.append("\r\n");
w.write(outsb.toString());
w.flush();
return false;
}
String[] split = cmd.split(";");
String insertURI = split[0];
String targetURI = split[1];
outsb.append("Insert URI: ").append(insertURI);
outsb.append("Target URI: ").append(targetURI);
FreenetURI insert = new FreenetURI(insertURI);
FreenetURI target = new FreenetURI(targetURI);
try {
FreenetURI result = client.insertRedirect(insert, target);
outsb.append("Successfully inserted to fetch URI: ").append(result);
} catch (InsertException e) {
outsb.append("Finished insert but: ").append(e.getMessage());
Logger.normal(this, "Error: "+e, e);
if(e.uri != null) {
outsb.append("URI would have been: ").append(e.uri);
}
}
} else if(uline.startsWith("STATUS")) {
outsb.append("DARKNET:\n");
SimpleFieldSet fs = n.exportDarknetPublicFieldSet();
outsb.append(fs.toString());
if(n.isOpennetEnabled()) {
outsb.append("OPENNET:\n");
fs = n.exportOpennetPublicFieldSet();
outsb.append(fs.toString());
}
outsb.append(n.getStatus());
if(Version.buildNumber()<Version.getHighestSeenBuild()){
outsb.append("The latest version is : ").append(Version.getHighestSeenBuild());
}
} else if(uline.startsWith("ADDPEER:") || uline.startsWith("CONNECT:")) {
String key = null;
if(uline.startsWith("CONNECT:")) {
key = line.substring("CONNECT:".length()).trim();
} else {
key = line.substring("ADDPEER:".length()).trim();
}
String content = null;
if(key.length() > 0) {
// Filename
BufferedReader in;
outsb.append("Trying to add peer to node by noderef in ").append(key).append("\r\n");
File f = new File(key);
if (f.isFile()) {